Importing CSV files
Importing CSV files allow users to import data easily into Parse tables.
To begin with this tutorial, you will need:
- An app created at Back4App.
- See the Create New App tutorial to learn how to create an app at Back4App.
Step 1 - Create a New Back4App App
First of all, it’s necessary to make sure that you have an existing app created at Back4App. However, if you are a new user, you can check this tutorial to learn how to create one.
Step 2 - Create a Class for importing data
In your newly created App, go to the
Database Browser and click the
Create a class button
Choose to crate a
Custom class and give it a name. I called mine
TestClass but you can call yours anything you like.
Remember that by convention classes start with an Uppercase letter, are CamelCase and does not contain special characters such as spaces and symbols.
Create class when you’re done.
Step 3 - Creating the CSV file
The CSV file must be in the correct format in order to be imported.
Correct format parameters:
- Separation character must be a comma
,and NOT a semicolon
- Adjust your Spreadsheet software to output commas as separation characters
- First line will be the Column Names
- Parse will automatically convert Strings, Numbers and Booleans
- Dates must have two columns:
date.__typespecifies the Date type
date.isospecifies the Date Format
- GeoPoints must have three columns:
geo.__typespecifies the Geopoint type
geo.latitudespecifies the Latitude
geo.longitudespecifies the Longitude
- Arrays are passed in double quotes
So, for your reference, a few examples:
Three columns: columnStringA will hold strings, columnStringB will also hold strings, columnNumberC will hold numbers
1 2 3 columnStringA,columnStringB,columnNumberC stringA,StringB,12 stringA2,StringB2,13
Two columns: columnStringA will hold strings, columnBooleanB will hold Booleans
1 2 3 columnStringA,columnBooleanB stringA,TRUE stringA2,FALSE
Two columns: columnStringA will hold strings, columnArrayB will hold arrays
1 2 3 columnStringA,columnArrayB stringA,"[1,2,3]" stringA2,"["A", "B", "C"]"
Two columns: columnStringA will hold strings, second column will hold a date in the ISO format
1 2 3 columnStringA,date.__type,date.iso stringA,Date,2020-01-16 stringA2,Date,2020-01-17
Two columns: columnStringA will hold strings, second column will hold a GeoPoint
1 2 3 columnStringA,geo.__type,geo.latitude,geo.longitude stringA,GeoPoint,1,2 stringA2,GeoPoint,-5,-6
You can find a sample CSV file for download here:
Step 4 - Importing the Data
With your newly created class selected in the
Database Browser, on the top right corner of the screen, click the
Notes button and select
Upload a file button, choose your CSV file and click the
Step 5 - Wait for an eMail confirmation
As CSV files can get quite big, an asynchronous operation is fired to import your data in background, which means you will not see any progress of importing nor success message. At the end of the operation you will receive an email message either telling the operation was successful and your data was imported, or telling the operation wasn’t successful and explaining which coluns/lines failed.
If you try to refresh your dashboard before receiving this email, you might see missing data or even no data at all, as the operation is still ongoing.
Once you get the email an if your import was successful, we recommend hard refreshing your browser (CMD + Shift + R on a Mac, CTRL + Shift + R in Windows, both for Chrome) to ensure the new schemas are retrieved and your data displays properly.