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(string $id, SplFileObject $file, int $headerRow = 1, int $sheetNumber = 1): DataTable
Parameters
Parameter | Type | Description |
---|---|---|
$id | string | The Id of the Data Table whose contents will be replaced |
$file | SplFileObject | The File to upload. Must be a CSV, XLS or XLSX file |
$headerRow | int | Optional The index of row containing column headers. Row counting starts at 1. |
$sheetNumber | int | Optional The index of the worksheet to import for Excel files. Sheet counting starts at 1. Defaults to 1. |
returns | DataTable | The Data Table which replaced the previous Data Table |
Example
<?php
/*
* This example demonstrates replacing a Data Table in Cataltyic
* with a file.
*/
require_once(__DIR__ . '/vendor/autoload.php');
use Catalytic\SDK\CatalyticClient;
$catalytic = new CatalyticClient();
$dataTableToUpload = new SplFileObject('/Users/alice/Downloads/mycsv2.csv');
$dataTable = $catalytic->dataTables()->replace('7f0594eb-9e02-46f1-b897-a1fc0a9786ca', $dataTableToUpload);
Updated almost 4 years ago