Replace a Data Table

Replace the contents of an existing table with a CSV or Excel file.

πŸ‘

Permissions Required

You must have Edit permissions to the data table for this request to succeed

Method Signature

replace(id: string, filePath: string): Promise<DataTable>;
replace(id: string, filePath: string, headerRow: number): Promise<DataTable>;
replace(id: string, filePath: string, headerRow: number, sheetNumber: number): Promise<DataTable>;
replace(id: string, filePath: string, callback: ClientMethodCallback<DataTable>): void;
replace(id: string, filePath: string, headerRow: number, callback: ClientMethodCallback<DataTable>): void;
replace(id: string, filePath: string, headerRow: number, sheetNumber: number, callback: ClientMethodCallback<DataTable>): void;

Parameter

ParameterTypeDescription
idstringThe id of the Data Table whose contents will be replaced
filePathstringThe local path of the CSV, XLS or XLSX file
whose contents will replace the existing Data Table
tableNamestringOptional The name of the table to create. Defaults to
the uploaded file name.
headerRownumberOptional The index of row containing column headers.
Row counting starts at 1.
sheetNumbernumberOptional The index of the worksheet to import for Excel files.
Sheet counting starts at 1. Defaults to 1.
returnsDataTableThe newly created Data Table

Example

/*
 * This example demonstrates replacing a Data Table in Cataltyic
 * with a file.
 */
const { CatalyticClient } = require('@catalytic/sdk');

const catalytic = new CatalyticClient();

const existingTableId = '10000000-0000-0000-0000-000000000001';
const filePath = '/path/to/local/file.xlsx';
const tableName = 'New Data Table';
const headerRow = 1;
const sheetNumber = 1;
const dataTable = await catalytic.files.replace(existingTableId, filePath, tableName, headerRow, sheetNumber);

console.log(`Replaced Data Table "${dataTable.name}" with "${filePath}"`);