I am trying to add a CSV that contains lat/long coordinates as a layer to a project in QGIS but I keep getting a 'layer is not valid' error. Here is a picture of the data preview before I click Add:

enter image description here

And here's the error message I'm getting:

CRITICAL Layer is not valid : The layer file:///(path)/(name)?type=csv&detectTypes=yes&xField=Longitude%0D(Decimal%20format)&yField=Latitude%0D(Decimal%20format)&crs=EPSG:4326&spatialIndex=no&subsetIndex=no&watchFile=no is not a valid layer and can not be added to the map. Reason:

Note: I didn't include the file path and file name in the Error message because this is a work-related project. And yes, the reason is blank. It's driving me insane!

  • Hard to tell without taking a look at the csv. First check if you have chosen the correct decimal separator within "record and fields options". If thats not an issue, you need to check your csv for errors using a validator (which might be problematic if its work-related) or by hand using a texteditor
    – MrXsquared
    Dec 7, 2019 at 20:49
  • Maybe you can find the reason in the Log Messages panel (menu View, Panels, Log Messages). Also, try disabling the Detect field types option. Dec 7, 2019 at 21:48
  • Re: Gabriel, I got the error message by opening the log messages panel. It doesn't include the reason.
    – vastava
    Dec 8, 2019 at 21:32
  • Re: MrXsquared, I've messed with the settings in the data source manager and tried practically every permutation and no dice. At your suggestion, I opened the csv in a texteditor and couldn't find any formatting errors. What sort of errors were you thinking I'd find?
    – vastava
    Dec 8, 2019 at 21:34

2 Answers 2


I just had this exact problem. Turns out that (for me) it was because the file I was attempting to import existed on a network drive. (so the usual rather lengthy pathname towards the file). I moved the data file onto a local folder (like C:\Documents) and it worked fine.


I also just had this problem, for me, it turned out to be because the CSVs I was generating via HeidiSQL did not have double quote enclosing on the fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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