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

ParameterTypeDescription
idStringThe Id of the Data Table whose contents will be replaced
fileFileThe File to upload. Must be a CSV, XLS or XLSX file
headerRowIntegerThe index of row containing column headers.
Row counting starts at 1.
sheetNumberIntegerThe index of the worksheet to import for Excel files.
Sheet counting starts at 1. Defaults to 1.
returnsDataTableThe 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);
    }
}