Transform a bundle with multiple arrays into multiple json objects made from those arrays

:bullseye: What is your goal?

I want to take a list of transactions in a credit card statement (pdf) and parse them into a Google sheet which each field (transaction date, posting date, etc.) mapped to a separate column.

:thinking: What is the problem & what have you tried?

I use Gemini to read the statement, but it returns the data in a single bundle with each field contained in an array (see attached image).

How do I create an array of json objects (representing each transaction) that’s made of values from each array?

{
transaction_date: “2025-12-01”,
posting_date: “2025-12-03”,
merchant_code: “bananarepublic”,
amount: “123”
}

If there is a better way to capture transaction information from a PDF and parse it into a Google Sheet, I’m open to that too.

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

Hey Chris,

use a dedicated PDF OCR app instead of a generic LLM. Any of them will read the PDF and return a valid JSON as an output.

For Gemini - just tell it what you want the output as. Can you show a screenshot of what the output looks like at the moment?

Cause the one you are showing is from a tools module and it looks like its a collection of arrays instead of an array of collections and the data doesn’t look right.

I’ll give that a try. Thanks!

The LLM (Gemini Pro) does work, but returns everything in a single bundle with an array for each of the properties that I’m grabbing (transaction date, posting date, description, amount). See attached. I don’t know how to take that one payload and re-organize so that each object instance represents a single transaction with all the transaction information (transaction date, posting date, description, amount).

Welcome to the Make community!

You could use the Make Code module to do something like this:

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":2,"module":"code:ExecuteCode","version":0,"parameters":{},"mapper":{"language":"javascript","input":[{"name":"data","value":"{{1.collection}}"}],"dependencies":[],"inputFormat":"editor","codeEditorJavascript":"const { data } = input;\n\nconst array = data.transaction_date_array.map((_, i) => ({\n  transaction_date: data.transaction_date_array[i],\n  posting_date: data.posting_date_array[i],\n  merchant_code: data.merchant_code_array[i],\n  amount: data.amount_array[i]\n}));\n\nreturn { array }"},"metadata":{"designer":{"x":2534,"y":-1214},"restore":{"expect":{"language":{"mode":"chose","label":"JavaScript"},"input":{"items":[null]},"inputFormat":{"label":"Code editor"}}},"expect":[{"name":"language","type":"select","label":"Language","required":true,"validate":{"enum":["javascript","python"]}},{"name":"input","type":"array","label":"Input","spec":{"type":"collection","label":"Variable","spec":[{"name":"name","type":"text","required":true,"validate":{"pattern":"^[a-zA-Z0-9_]{1,32}$","min":1,"max":32},"label":"Name"},{"name":"value","type":"any","label":"Value"}],"name":"value"}},{"name":"inputFormat","type":"select","label":"Input format","required":true,"validate":{"enum":["editor","string"]}},{"name":"codeEditorJavascript","type":"editor","label":"Code","required":true}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

Hope this helps! If you are still having trouble, please provide more details.

— @samliew

2 Likes

Hi @samliew !

I implemented your Make Code module and it worked. Thanks a lot!

Your entire post is actually a treasure trove of information. Thanks for taking the time to write it all down and help me through my sticking point.

1 Like

No problem, glad I could help with your question:
"Transform a bundle with multiple arrays into multiple json objects made from those arrays"   :tada:

Just to add on to the answer: Sometimes the Make Code module takes longer than expected, thus using more than one credit. If you are using plain JavaScript code like the example above, you might want to consider switching to using my custom app’s “Execute JavaScript” module.

For more information, see the thread “[App] Sam’s Toolbox of Useful Modules” on how to install and start a new topic if you have any questions on how to use it.

Save headaches and operation credits with these utility modules:

  • Chunk Text
  • Chunk Array
  • Chunk Words
  • Multiple Find & Replace
  • Collection to Array/String List
  • Execute JavaScript
  • Estimate Tokens
  • Calculate Difference Between Two Dates
  • Get Next Business Day (with holidays)
  • List Upcoming Dates of Day of Week
    … and more!

— @samliew