Skip to content

Instantly share code, notes, and snippets.

Last active November 21, 2022 19:34
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
let table = base.getTable('People');
let csvFile = await input.fileAsync(
'Pick a CSV file to upload',
{allowedFileTypes: ['.csv'], hasHeaderRow: true}
if(csvFile) {
let fileRows = csvFile.parsedContents;
output.text('Here are the first 10 records of your file');
output.table(fileRows.slice(0, 10));
let proceed = await input.buttonsAsync(
'Would you like to continue with this import?',
[{label: 'Proceed', variant: 'primary'}, 'Cancel']
if(proceed == 'Proceed') {
let newRecords = => ({
fields: {
'First Name': fileRow.first_name,
'Last Name': fileRow.last_name,
output.text('Importing data');
while (newRecords.length > 0) {
await table.createRecordsAsync(newRecords.slice(0, 50));
newRecords = newRecords.slice(50);
output.text('Import completed');
Copy link

Hello! Great code!
Do you know how I could hard code the file? (I don´t want to select it all the time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment