Upload a Spreadsheet as a Data Table
Upload a spreadsheet file to Catalytic to create a new Data Table.
Method Signature
DataTable Upload(FileInfo file, string tableName = null, int headerRow = 1, int sheetNumber = 1);
async Task<DataTable> UploadAsync(FileInfo file, string tableName = null, int headerRow = 1, int sheetNumber = 1);
Parameters
Parameter | Type | Description |
---|---|---|
file | FileInfo | 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 newly created Data Table |
Example
/*
* This example demonstrates uploading a Data Table to Cataltyic
*/
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);
// Upload the file
var result = catalytic.DataTable.Upload(file, "Example Table");
Console.WriteLine($"Uploaded Data Table has ID {result.Id}");
}
}
}
Updated almost 3 years ago