4

I'm trying to import a CSV file in QGIS 3.4 using the common method of "Add Layer" > "Add Delimited Text Layer". But QGIS is reading every row of the dataset as a column title, and nothing is in a row below those columns. See the screenshot below:

enter image description here

I thought there might be some weird formatting issues, so I tried saving the dataset various ways (xlsx, csv, txt) but no success.

Then I tried to create a very simple csv file from scratch as a test, which looks like this:

enter image description here

And when trying to "Add Delimited Text Layer" with this file I get the same problem. All rows are read as column headers:

enter image description here

What obvious thing am I missing? It is as if this tool suddenly does not work, though I have used it many times before.

  • 4
    There is a problem with line breaks. I would suggest to open the file inside a good text processor, like notepad++, to see what is wrong – Andreas Müller Oct 10 '19 at 19:50
  • Have you tried "Custom Delimiters"? often when I have a problem opening a CSV, it's because it's not Comma separated Values but Tab separated or semicolons – LeoC Oct 10 '19 at 19:52
6

Most definitely there is an End Of Line issue in the CSV file. I would guess QGIS is on a Windows machine, and the CSV only has Carriage Retruns (CR) or linefeeds (LF), while it need both (CR+LF, or 0x0A + 0x0D).

A simple fix is to convert all line breaks of the CSV file into CR+LF. Luckily it is an easy operation, and there are tons of options:

  • Under Linux use the unix2dos command line utility, awk, perl, or whatever you feel like.
  • Online there are also scores of alternatives. One I just tried: http://newline.nadav.org/

enter image description here

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.