Transformations: Lists and Objects
Utilize structured column types to manage complexity in your document pipelines
When lists and objects are useful
Let’s say you have an invoice that looks like this:
“Primitive” column types like text
and number
would help you extract the invoice addressee and the total amount due. But what if you wanted to parse the invoice table? Using primitive types, you would have to add a text column and three number columns to capture the description, time, price and total for every row. Even if you know ahead of time how many rows there will be in the invoice, this is a time-consuming process that should be easier.
With list
and object
column types, extracting an invoice table requires creating just a single operation!
Walkthrough
To see list
and object
operations in action, head over to the Trellis dashboard and create a new project. Select “Start from scratch”, name your project and select “File Upload”.
In the next page, select File URL, and paste in the following URL:
(This is where our invoice is publicly hosted)
Then click “Upload”. You just uploaded a document to your very own Trellis Transformation!
Next, it’s time to extract the transformation table. Click “Add new column” - you should see a menu like this:
Click on “Extract data”. Name the new column “Invoice Table Rows”, and from the column type dropdown, select “List”.
For the task description, enter the following:
- “Extract the invoice table rows from the {{Assets}}”
Now, lets define an invoice row. Under the section titled “Operations for Invoice Table Rows list”, enter “Row” for the column name, and change the type from “Text” to “Object”. You can leave the task description blank.
A new button called “Add Nested Operation” should pop up - click it 4 times for each column in your invoice table. Now, add in the column names, types, and task descriptions as listed below:
-
Description (Text) (N/A)
-
Time spent (Number) (In hours)
-
Price (Number) (In pounds)
-
Total (Number) (In Pounds)
Add the column using the “Save and Preview” button at the bottom. Now, watch the transformation go to work!
When the transformation is finished running, click on the asset name (in the “Assets” column) and expand the “Invoice Table Rows” parameter. You should see your freshly extracted table!
For more information on using column types in Trellis’ API, head over to our guide here!
Transformation: column_type
Our guide to Transformation column types