Uploading data from CSV files
The administrator can upload new data rose to tables as CSV files which can be exported from any spreadsheet program. There are two ways of uploading CSV files: Uploading to an existing table, and creating a new table by uploading a file. The expected layout of the CSV file is the same in both cases
Expected file format
The easiest way of seeing the file format expected is to create a table with the appropriate rows, insert a few rows with dummy data, then download the table as a CSV file from the administrators view of the table (Table data card in the table page). The first row should contain the field names. This should either be the name of the field you have entered, or variable name for that field (shown as a column in the list of fields). Cells In the rows below should contain the data matching the field name for that column.
Creating a new table from CSV upload
CSV (Comma Separated Values) - widely used plain text format. You can export Excel sheet to CSV and create table just in few seconds using import from CSV.
Create table using import from CSV
Choose Menu > Tables > Create Table > Create from CSV
- Choose table name. Read Creating tables for more information.
- Choose CSV file from local disk of you computer.
- Click create.
If CSV file correct format in few seconds Saltcorn will create table from CSV. Note that if you try lo load big CSV file the export can take time. Be patient.
Uploading to an existing table
Also for existing table you can import data from CSV file.
- Choose Menu > Tables > Table data > Upload CSV for start
There are few tips about CSV import:
- First line of file is the list of field names. Underscore _ is unsupported in field name
- List of values in CVS for Bool field: true false yes no on off y n t f.
- Date format is moment.ISO_8601.
If the CSV file is larger than 1 MB, Saltcorn switches to using a different import method (PostgreSQL's COPY) into the database. This is much faster, but you may not get very good error messages. In addition if there is an error then no rows will be imported. For smaller files, valid rows will imported and invalid row will be rejected - profile is larger than 1 MB it is all or nothing. You do not get good error messages with a large file, try uploading the first few thousand rows.