I am a complete noob and know next to nothing about coding, so bear with me please.
I download order reports on ebay and upload them into my airtable base for a partner to gather the data from. They are downloaded automatically in .csv format, with no option to omit any data beforehand. The automatic csv import tool that airtable provides doesn’t work for these because they contain 63 columns. I only use 29 columns, and I reorganize them a little as well. I am trying to find a way to make this automatic.
I thought I would try and use the scripting extension to do this. I chose the example “spreadsheet importer” to use as a template. My knowledge of scripting is about 1 html website I made in grade 7 computer class 13 years ago above the average persons level of knowledge, aka slim to none. Here is how far I got before getting confused:
// Ask the user to import a CSV file containing a header row
let csvFileResult = await input.fileAsync(
‘Upload a CSV file’,
{allowedFileTypes: i‘.csv’], hasHeaderRow: true}
);
// The file importer will automatically parse contents for many file types, including CSV files
let csvRows = csvFileResult.parsedContents;
// Edit this to the name of a table in your base
let table = base.getTable(‘Critical Info’);
let shouldContinue = await input.buttonsAsync(
Import ${csvRows.length} records from ${csvFileResult.file.name} into ${table.name}?
,
,{label: ‘Yes’, variant: ‘primary’}, ‘No’]
)
if (shouldContinue === ‘Yes’) {
// Create new records from the CSV.
// Edit these field and property names to match your table and CSV data
let newRecords = csvRows.map(csvRow => ({
fields: {
'Order Number': csvRow./OrderNumber],
'Buyer': csvRow.BuyerUsername,
'Item Number': csvRow.ItemNumber,
'Item Title': csvRow.ItemTitle,
}
}));
// A maximum of 50 record creations are allowed at one time, so do it in batches
while (newRecords.length > 0) {
await table.createRecordsAsync(newRecords.slice(0, 50));
newRecords = newRecords.slice(50);
}
}
This got me nowhere, I decided to run it to test before continuing to add fields and none of them worked. What am I doing wrong? Am I even on the right track at all?