Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.