Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to write out a CSV file from a vector layer made up of points using the python console in QGIS. I've tried the following command:

QgsVectorFileWriter.writeAsVectorFormat(layer_Map, Folder + "my_shapes.csv", "CP1250", None, "delimitedtext")

but it does not like the delimitedtext parameter (if I use ESRI Shapefile it works fine). I have not been able to determine what other options can be used instead of ESRI Shapefile.

I find the Quantum GIS API documentation to be quite confusing, but I hope I will get used to it soon.

Thanks in advance for any help.

share|improve this question
Are you getting an error message? If so, please edit your question to include the error. – user3461 Mar 20 '13 at 16:17
No error message, but the number 1 is returned, meaning that the action was not successful. If I use the ESRI Shapefile option the action returns 0 (i.e. successful) – Dom Mar 20 '13 at 16:22
up vote 2 down vote accepted

Just use the "CSV" argument :

currentLayer = qgis.utils.iface.mapCanvas().layers()[0]
QgsVectorFileWriter.writeAsVectorFormat(currentLayer, csvpath, "CP1250", None, "CSV")

I get the 0 exit code, and the CSV file is well created :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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