Blog

How to assign column types during data import

by on March 20, 2015

In another post, we described a feature where you can import data to Backendless using CSV files. In that post, we used CSV files that already had the data type defined for each column. For example:

With that approach, the import process is completely automated since Backendless knows what the data type is for each value. However, what would happen if the imported CSV file(s) does not provide that information? Backendless handles that scenario rather gracefully – it provides a very easy-to-use interface where you can assign the proper data types. Consider the following data file:

[table caption=”Sample Data” width=”500″ ]
“objectId”,”created”,”updated”,”cuisine”,”name”,”ownerId”,
“277AA15C-E863-6307-FF86-D048F78E4B00″,”01/17/2015 00:00:00 GMT+0000″,”01/21/2015 00:00:00 GMT+0000″,”fastfood”,”McDonald’s”,null
“761AF742-567F-6C4A-FFA9-9A17138A0A00″,”01/17/2015 00:00:00 GMT+0000″,”01/21/2015 00:00:00 GMT+0000″,”italian”,”Buca Di Bepo”,null
“834AA1E2-1B8C-46F0-FFA9-BD2742B65500″,”02/19/2015 00:00:00 GMT+0000″,null,”pizzeria”,”Mister Cat”,null
“E1118F7D-AF69-8630-FF53-4A3FD5A90900″,”02/19/2015 00:00:00 GMT+0000″,null,”japanese”,”Evraziya”,null
“EB628266-A55A-E52A-FF1F-326D4E5D0200″,”01/17/2015 00:00:00 GMT+0000″,”01/21/2015 00:00:00 GMT+0000″,”mexican”,”Cantina Laredo”,null
“FFE1C0BB-CFC6-738F-FFC1-7A8A66ED3A00″,”01/15/2015 00:00:00 GMT+0000″,”01/21/2015 00:00:00 GMT+0000″,”bakery”,”Endless Sweets”,null
[/table]

As you can see the header row has no information about the column types. When importing the file to Backendless using the Console (you can download the file from here), the file is uploaded and the user is then presented with the following interface:

As you can see, for every user-defined column (columns objectId, created and updated are the system-level columns), Console prompts the user to specify the data type. If you were to import multiple CSVs, there would be a similar interface for each file without the data types. The interface is also aware of columns representing relations and provides a way to specify those. Once the types are set, click the Finalize Import button to finish the import.