- 12 May 2023
- 3 Minutes to read
Using CSV files
- Updated on 12 May 2023
- 3 Minutes to read
👤 This documentation is intended for Secondary Contributors and above.
Typically, Workspace Administrators would first connect organization's databases before team membmers start using Preset.
However, Primary Contributors and Secondary Contributors can still create datasets, charts, and dashboards from CSV files before connecting databases.
Connect a Database and Enable Uploads
If you created your workspaces before April 13, 2023, a CSV file cannot be uploaded without a database connection. Be sure to add your database first to make use of the CSV upload feature!
In order for the database to accept the CSV, you need to enable data uploads. Data uploads will be enabled by default. If data uploading is disabled, follow the below steps.
Start by navigating to the Database Connections link from your settings.
and then select the Edit pencil icon for your database.
The "Edit database" panel appears. Select the Advanced tab and then expand the Security panel.
In the Schemas Allowed for CSV Upload field, enter the name(s) of any schemas in your database that should be available for CSV data uploads. If more than one, separate each by a comma.
In the Allow data upload field, select the checkbox.
If there are specific schemas to house the CSV upload, specify those schemas in the text box shown.
Lastly, select Finish.
To confirm, in the Databases screen under the "CSV upload" column header, ensure that a checkmark is displayed for your database row entry.
In the example below, CSV data upload has been enabled.
Configure the CSV Upload
In the Toolbar, select Upload file to database, and then, in the sub-menu, select Upload CSV.
Alternatively, you can hover your cursor over the plus + icon, then Data, and then select Upload CSV to database from any screen in Preset.
The "CSV to Database configuration" screen appears.
In the CSV Upload* field, select Choose File and select the CSV file on your local or network system.
In the Table Name* field, enter a memorable name for the table to be created from the CSV data.
In the Database field, select the database to use.
In the Schema field, select the schema associated with the selected database.
In the Delimiter* field, specify the symbol used to delimit the data. For a whitespace, use \s+.
Other CSV Configurations
In the Table Alerady Exists* field, select what to do if a table already exists: Fail (do nothing), Replace (drop and recreate table), or Append (insert data).
In the Skip Initial Space field, select to skip spaces after the delimiter.
In the Skip Blank Lines field, select to skip blank lines instead of interpreting them as NaN values.
In the Columns To Be Parsed as Dates field, add a comma-separated list of columns that should be parsed as dates.
In the Interpret Datetime Format Automatically field, select to use Pandas to automatically interpret the datetime format.
In the Decimal Character field, enter a character to interpret as a decimal point.
In the Index Column field, enter the column to use as row labels for the data frame. Leave empty if there is no index column.
In the Mangle Duplicate Columns field, select the checkbox to specify duplicate columns as "X.0, X.1".
Null Values: List of values that should be treated as null, in JSON format.
In the Dataframe Index field, select to write the dataframe index as a column,
In the Column Label(s) field, enter one or more column labels for index columns. If none are provided and if Dataframe Index is true, then index names are used.
In the Header Row field, enter 0 if your CSV data already has a header row or leave it empty if there is no header row present.
In the Rows to Read field, enter the number of rows to read.
In the Skip Rows field, enter the number of rows to skip at the start of the file.
When done, select Save.
After selecting Save, you will be taken to the "Datasets" screen where your newly-loaded CSV and associated dataset appear.
To learn morea bout datasets, visit this page.
Visualize the CSV Data
From here, you can select the dataset to launch it on the Chart Builder page and proceed with configuring a chart.