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.
-
Are you getting an error message? If so, please edit your question to include the error.user3461– user34612013年03月20日 16:17:08 +00:00Commented Mar 20, 2013 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– Dom2013年03月20日 16:22:20 +00:00Commented Mar 20, 2013 at 16:22
1 Answer 1
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 :)