Help

Export CSV with automation or script

Topic Labels: ImportingExporting
2357 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Nasir_Farmani
4 - Data Explorer
4 - Data Explorer

Hi, i’m looking for a script or automation of airtable to put my table into a csv file. How can i do it?
i found this. how can i download it?

// display app title
output.markdown('# Export to CSV');

// set the table name
let sourceTableName = "Search";

// identify the fields to be exported
let aFieldList = ["Name","Surname","Linkedin Link"];

// get the source data
let sourceTable = base.getTable(sourceTableName);

// get the data set for 2018/2019
let result = await sourceTable.selectRecordsAsync();

// set a counter for testing
let count = 0;

// iterate across all the records
let csvFile = "";
let csvRow  = "";
let csvItemCount = 0;
for (let record of result.records)
{
    // build the current csv row
    csvRow = "";
    for (var i in aFieldList)
    {
        csvRow += record.getCellValueAsString(aFieldList[i]) + ((i < aFieldList.length - 1) ? "," : "");
    }

    // add the row to the file
    csvFile += csvRow + "\r\n";
    csvItemCount += 1;

    // increment the row counter
    count += 1;

    // break if testing
    if (count > 100)
      break;
}
// display the contents of the csv file

output.inspect(csvFile);

1 Reply 1
Brian_Sweeny
6 - Interface Innovator
6 - Interface Innovator

Hi Nasir!You probably figured this out already but I thought perhaps other might have the same question. Airtable provides an easy way to export to CSV. Check out the screenshot attached.

If you need more help with Airtable, feel free to schedule a session.

Screenshot 2024-05-14 at 5.08.26 PM.png