Upload a Spreadsheet as a Data Table
Upload a spreadsheet file to Catalytic to create a new Data Table.
Returns a reference to the created Data Table.
Method Signature
uploadDataTable(SplFileObject $file, string $tableName = null, int $headerRow = 1, int $sheetNumber = 1): DataTable
Parameters
Parameter | Type | Description |
---|---|---|
$file | SplFileObject | The File to upload. Must be a CSV, XLS or XLSX file |
$tableName | string | Optional The name of the table to create. Defaults to the uploaded file name. |
$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. Defaults to 1. |
returns | DataTable | The uploaded Data Table |
Example
<?php
/*
* This example demonstrates uploading a Data Table to Cataltyic
*/
require_once(__DIR__ . '/vendor/autoload.php');
use Catalytic\SDK\CatalyticClient;
$catalytic = new CatalyticClient();
$dataTableToUpload = new SplFileObject('/Users/alice/Downloads/example.csv');
$dataTable = $catalytic->dataTables()->upload($dataTableToUpload, 'Example Table');
echo "Uploaded Data Table has id " . $dataTable->getId() . PHP_EOL;
Updated almost 4 years ago