How can I force data types when importing csv files?
From CSV to CSVT
Given a csv file called file.csv
with the following structure:
id | desc | lon | lat | price |
---|---|---|---|---|
1 | apartment | -3 | 42 | 199000 |
2 | condo | -3 | 43 | 459000 |
You can create a type definition file, file.csvt
, as:
"Integer","String","Real","Real","Real"
For more information, you can check CSV GDAL documentation. Secondly, you need to compress both files and upload it dragging and dropping it on CARTO dashboard UI or via the Import API.
That will create a column price
as a double precision one, as opposed to the integer type when you don’t use the file.csvt
file.
What’s next?
To get a big picture about CARTO data management, you can continue reading Preparing and Formatting Data. The CARTO Glossary also contains useful definitions of all of the components, processes, and technologies regarding data management.