Skip to main content
Question

Extracting data from a csv or json attachment

  • February 28, 2026
  • 1 reply
  • 8 views

CKARC
Forum|alt.badge.img+10

I am importing records that have attachments, and that attachment can be csv or text or json  . . whatever. Airtable ai wont read it, can a script in an automation read data from an attached non image file?

1 reply

TheTimeSavingCo
Forum|alt.badge.img+31

Yeap, I’ve set up an example here for you to check out where we use a script to parse a CSV and then use a repeating group to create one record per line in the CSV

 

We need to use the expiring download URL for the script input variable:

 

Here’s the CSV text:

column1, column2
a,b
c,d

And here’s the code:

let { csvUrl } = input.config();

let res = await fetch(csvUrl);
let csvText = await res.text();

// output full raw csv
output.set("csvText", csvText);

function parseCsv(text, delimiter = ",") {
let rows = text.trim().split("\n").map(r => r.split(delimiter));
let headers = rows.shift();

return rows.map(row => {
let obj = {};
headers.forEach((h, i) => {
obj[h.trim()] = (row[i] || "").trim();
});
return obj;
});
}

let records = parseCsv(csvText);

output.set("rows", records);