Help

Export CSV with automation or script

Topic Labels: ImportingExporting
2099 0
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);

0 Replies 0