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

ParameterTypeDescription
fileFileInfoThe File to upload. Must be a CSV, XLS or XLSX file
tableNamestringOptional The name of the table to create. Defaults to
the uploaded file name.
headerRowintOptional The index of row containing column headers.
Row counting starts at 1.
sheetNumberintOptional The index of the worksheet to import for Excel files.
Defaults to 1.
returnsDataTableThe 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}");
        }
    }
}