This content applies to a previous version of CARTO
In October 2021 we released a new version of our platform. You can find the latest documentation at docs.carto.com
How to Force Data Types When Importing CSV Files
Learn how to use .csvt file to force data types on your csv imports.
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. Next, compress both files and upload them by dragging and dropping on the CARTO dashboard UI or via the Import API.
This approach will create a price column as a double precision type, as opposed to the integer type when you don’t use the file.csvt file.
What’s next?
To understand CARTO data management better, continue reading Preparing and Formatting Data. The CARTO Glossary also contains useful definitions related to data management components and technologies.
