Replace a Data Table
Replace the contents of an existing table with a CSV or Excel file.
Method Signature
DataTable replace(String id, File fileToUpload);
DataTable replace(String id, File fileToUpload, Integer headerRow, Integer sheetNumber);
Parameters
Parameter | Type | Description |
---|---|---|
id | String | The Id of the Data Table whose contents will be replaced |
file | File | The File to upload. Must be a CSV, XLS or XLSX file |
headerRow | Integer | The index of row containing column headers. Row counting starts at 1. |
sheetNumber | Integer | The index of the worksheet to import for Excel files. Sheet counting starts at 1. Defaults to 1. |
returns | DataTable | The newly replaced Data Table |
Example
/*
* This example demonstrates replacing a Data Table in Cataltyic
* with a file.
*/
import org.catalytic.sdk.CatalyticClient;
import org.catalytic.sdk.exceptions.CredentialsNotFoundException;
import org.catalytic.sdk.exceptions.FileNotFoundException;
import java.io.IOException;
import java.io.File;
public class Program {
public static void main(String[] args) throws Exception {
// Create and initialize Catalytic SDK Client
CatalyticClient catalytic = new CatalyticClient();
// Replace a specific Data Table by id with a spreadsheet
File file = new File("/Users/alice/table.csv");
DataTable dataTable = catalytic.dataTables().replace("f98b3a70-a461-46b1-b43a-3eb1cced3efd", file);
}
}
Updated almost 3 years ago