Import Transformer
Introduction
With the import transformer, you can import almost any text format into Datasaur. Currently, we limits the file extensions into .csv, .txt and .json.
Text-based projects
Creating a new import transformer will provide you with the following template, which works for Span labeling, Row labeling, and Span+Line labeling projects:
The import transformer is a function that takes the fileContent as a string, parsed using UTF-8 encoding, and returns a SimpleDocument that Datasaur can process.
SimpleDocument is an object that represents a document in Datasaur. It is a combined type that supports span labeling and row labeling. The structure of SimpleDocument is shown below:
Sample
This example shows how to label a .srt subtitle file and display timestamps as metadata. The file transformer script is shown below.
To get started:
Rename your file by adding the
.txtextension. You can use the sample file below.Click Create file transformer.
Enter a name, select Import, then click Create.
Paste the file transformer script to the editor. You can also upload it.

Go to Projects page and click Create a project.
In step 1, select the file transformer you just created in the File transformer dropdown. Finish the project creation and launch the project.

Your project is ready!

Notes:
You need to add Metadata extension to the project.
If you want the metadata to be available in the text editor, set
pinned: true.Use HTML code color for text color, border color, and background color.
Bounding box labeling projects
Bounding Box projects support import file transformers when creating a project from a PDF or image. The transformer script receives the paired answer file's content (not the raw PDF/image bytes) as a UTF-8 string, and must return a BoundingBoxSimpleDocument.
Pairing rule: the answer file must share the same basename as the media file (e.g. invoice.pdf + invoice.json). If no matching answer file is found, project creation fails with an ANSWER_FILE_NOT_FOUND error.
Here's a minimal file transformer that will apply a single bounding box to the document regardless of the answer file content:
If you have any questions, please reach out to support@datasaur.ai.
Last updated