Hello all, Thanks, Rafael.
Following Rafael's post and QGIS cookbook, I solved the issue. Attached is my script to read and convert .csv to .shp. I would like to share with you. Thanks for the help. Best wishes, Jiaqiu On 14/05/2013 16:53, "Rafael Varela Pet" <[email protected]> wrote: >2013/5/14 Jiaqiu Wang <[email protected]>: > >> I read some posts about how to import 'delimited text' using plugin in >> QGIS. >> >> I have plenty of .csv files to cope with. Do you know how to cope with >>it >> using python script ? Thank you very much for the help ! > >You can use both the "delimited text" or the OGR providers. In my >experience, the delimited text plugin is more flexible (for example, >you can exclude lines at the beginning of the file) but it has some >issues in QGIS 1.8 (see http://hub.qgis.org/issues/7493) > >As Benoît said you should check the cookbook. Also, you might find >useful the examples I've included in issue 7493. > >Best regards, >-- >Rafael Varela
# The script aims to transform .csv to raster from qgis.core import * import qgis.utils import os for i in range(60,820,20): filepath = "/yourpath/LegionPartD"+str(i)+".csv?" filename = "/yourpath/Shp/LegionPartD"+str(i)+".shp" uri = "%s&delimiter=%s&crs=EPSG:27700&xField=%s&yField=%s&zField=%s" % (filepath,",", "V1", "V2","V3") layer = QgsVectorLayer(uri, "LegionPartD60", "delimitedtext") # QgsMapLayerRegistry.instance().addMapLayer(layer) error = QgsVectorFileWriter.writeAsVectorFormat(layer, filename, "CP1250", None, "ESRI Shapefile") if error == QgsVectorFileWriter.NoError: print "write success!"
_______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
