2

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.

underdark
84.9k22 gold badges237 silver badges418 bronze badges
asked Mar 20, 2013 at 16:09
2
  • Are you getting an error message? If so, please edit your question to include the error. Commented 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) Commented Mar 20, 2013 at 16:22

1 Answer 1

3

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 :)

answered Mar 20, 2013 at 16:42

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.