Spreadsheet importer Scripting Extension only
Scripting Extension only
This script uses the file input to create records from a user-uploaded spreadsheet. You can manipulate the file data after its uploaded and before you save it back to your base. It can be adjusted to work with different file types, such as XLS(X) and JSON.
Example
// Ask the user to import a CSV file containing a header rowlet csvFileResult = await input.fileAsync('Upload a CSV file',{allowedFileTypes: ['.csv'], hasHeaderRow: true});// The file importer will automatically parse contents for many file types, including CSV fileslet csvRows = csvFileResult.parsedContents;// Edit this to the name of a table in your baselet table = base.getTable('Purchases');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 datalet newRecords = csvRows.map(csvRow => ({fields: {'Date': csvRow.Date,'Amount': csvRow.Amount}}));// A maximum of 50 record creations are allowed at one time, so do it in batcheswhile (newRecords.length > 0) {await table.createRecordsAsync(newRecords.slice(0, 50));newRecords = newRecords.slice(50);}}