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
DataTable Replace(string id, FileInfo file, int headerRow = 1, int sheetNumber = 1);
async Task<DataTable> ReplaceAsync(string id, FileInfo file, int headerRow = 1, int sheetNumber = 1);
Parameters
Parameter | Type | Description |
---|---|---|
id | string | The Id of the Data Table whose contents will be replaced |
file | FileInfo | 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 updated Data Table |
DataTable Replace(Guid id, FileInfo file, int headerRow = 1, int sheetNumber = 1);
async Task<DataTable> ReplaceAsync(Guid id, FileInfo file, int headerRow = 1, int sheetNumber = 1);
Parameter | Type | Description |
---|---|---|
id | Guid | The Id of the Data Table whose contents will be replaced |
file | FileInfo | 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 updated Data Table |
Example
/*
* This example demonstrates replacing a Data Table in Cataltyic
* with a file.
*/
using System.IO;
namespace Catalytic.Sdk.Examples
{
class Program
{
static void Main(string[] args)
{
var catalytic = new Catalytic.Sdk.CatalyticClient(Credentials.Default);
// create a file to upload
var file = new FileInfo(Path.GetTempFileName());
var csv = "\"Name\",\"Age\"\n\"Alice\",\"42\"\n\"Bob\",\"54\"";
File.WriteAllText(file.FullName, csv);
var existingTableId = "10000000-0000-0000-0000-000000000001";
// upload the file
var result = catalytic.DataTable.Replace(existingTableId, file);
}
}
}
Updated almost 4 years ago