I'm trying to upload a .csv file to my QGIS project via Pyqgis. According to the following thread Using non-spatial CSV with PyQGIS it should work that way:

uri = 'file///C:/Users/denni/Desktop/test.csv?delimiter=;'
table = QgsVectorLayer(uri, "table", "delimitedtext")

But I only get an empty layer in QGIS. I can't find the mistake in my code. What is wrong? The delimiter in the test.csv file is a ";", so that's not the problem. The path is correct. The script uploads a layer to QGIS so I guess the line 3 is correct as well...

  • 1
    You forgot the : in 'file:///...' – BERA Aug 10 at 12:28
  • ahhhh yes you are right.... Thanks for that :) now I have values in importet attribute table, but only one field. There should be two fields. Is there a way get two fields? – Dennis Jan Aug 10 at 12:50
  • 1
    ok, so the problem was the ; as delimiter. If I use , as a delimiter I get two fields. – Dennis Jan Aug 10 at 13:38

Your Answer

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

Browse other questions tagged or ask your own question.