4

I am working with QGIS on a Mac, and understand the process for importing a CSV file. However, I do not know how to create the CSVT file to define the CSV file's data types.

Can someone instruct me on how to do this?

8

A CSVT file is just a plain text file that you create with the extension .csvt. The file has a single line with the types for each column:

"Integer","Real","String"

Make sure there are no spaces between each , or type.

| improve this answer | |
  • I just closed the question this answer is on thinking that CSVT would be a general IT rather than GIS/spatial format, but then did some searches to try and be sure of that and did not find anything conclusive. If it should not be treated as a general IT format, can you let me know so that I can reverse my action? – PolyGeo Jun 25 at 3:46
  • @PolyGeo CSVT is an ogr thing in order to add types to csv. So best to reopen. – Nathan W Jun 25 at 12:36
2

You have to find a programme, where you can write the extention by hand. For windows you can do it in Gedit. First you type the line "Integer","real",... and so on, as it is written in previous answer and after clicking 'save as' you delete the given extention and type 'csvt' for example programme gives 'fields.txt' then you delete 'txt' and write csvt instead to get 'fields.csvt'. Then you click save. It worked for me. Good luck!

| improve this answer | |
0

You can either create the file in Excel (or similar) or a basic text editor using the correct format as noted above. Unfortunately Macs have a habit of adding .CSV or .TXT (depending on the software you use to create the file) after the .CSVT that you specified. In finder, right-click and select "get info" or use "Command I". in the window that pops up check the Name & Extension section. You may need to delete the .CSV or .TXT your application added after the .CSVT or simply change the extension to .CSVT. For example, I may have exported the CSVT file I created out of excel and specified the name as test.csvt but it was actually exported as test.csvt.csv (depending on your set-up the .csv at the end may be hidden). In Finder select the file, use Command I and under the Name & Extension remove the final .CSV to end up with test.csv Hope this helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.