Using CSV files
  • 07 Jul 2023
  • 3 Minutes to read
  • Dark
    Light

Using CSV files

  • Dark
    Light

Article summary

👤 This documentation is intended for Secondary Contributors and above.

Introduction

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

For workspaces created before April 13, 2023:

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.

Database connections.png

and then select the Edit pencil icon for your database.

CSV - Edit.png

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.

Allow data upload .png

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.

CSV data upload view.png

Configure the CSV Upload

In the Toolbar, select Upload file to database, and then, in the sub-menu, select Upload CSV.
Upload CSV.png

Alternatively, you can hover your cursor over the plus + icon, then Data, and then select Upload CSV to database from any screen in Preset.

Upload CSV file .png

The "CSV to Database configuration" screen appears.

Config.png

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

File Settings

File settings.png

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.

Columns

Screenshot 2023-05-12 at 3.06.16 PM.png

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.

Rows

Screenshot 2023-05-12 at 3.06.23 PM.png

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.



*: Required

When done, select Save.

After selecting Save, you will be taken to the "Datasets" screen where your newly-loaded CSV and associated dataset appear.

files settings - save.png

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.

Visualize the CSV data.png

Common Errors for CSV Uploads

See Google Sheets and CSVs


Was this article helpful?