[GRASS-SVN] r62273 - in grass/branches/releasebranch_7_0: . scripts/v.in.geonames
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 16 23:48:40 PDT 2014
Author: neteler
Date: 2014-10-16 23:48:40 -0700 (Thu, 16 Oct 2014)
New Revision: 62273
Modified:
grass/branches/releasebranch_7_0/
grass/branches/releasebranch_7_0/scripts/v.in.geonames/v.in.geonames.py
Log:
v.in.geonames: sync to trunk
Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
- /grass/trunk:61280,62144,62269
+ /grass/trunk:61280,62144,62269,62271
Modified: grass/branches/releasebranch_7_0/scripts/v.in.geonames/v.in.geonames.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/v.in.geonames/v.in.geonames.py 2014-10-17 06:47:02 UTC (rev 62272)
+++ grass/branches/releasebranch_7_0/scripts/v.in.geonames/v.in.geonames.py 2014-10-17 06:48:40 UTC (rev 62273)
@@ -41,10 +41,6 @@
infile = options['input']
outfile = options['output']
-
- #### setup temporary file
- tmpfile = grass.tempfile()
-
#are we in LatLong location?
s = grass.read_command("g.proj", flags='j')
kv = grass.parse_key_val(s)
@@ -61,19 +57,8 @@
if dbfdriver:
grass.warning(_("Since DBF driver is used, the content of the 'alternatenames' column might be cut with respect to the original Geonames.org column content"))
- # let's go
- # change TAB to vertical bar
- num_places = 0
- inf = file(infile)
- outf = file(tmpfile, 'wb')
- for line in inf:
- fields = line.rstrip('\r\n').split('\t')
- line2 = '|'.join(fields) + '\n'
- outf.write(line2)
- num_places += 1
- outf.close()
- inf.close()
-
+ with open(infile) as f:
+ num_places = sum(1 for _ in f)
grass.message(_("Converting %d place names...") % num_places)
# pump data into GRASS:
@@ -148,15 +133,14 @@
'timezone varchar(50)',
'modification date']
- grass.run_command('v.in.ascii', cat = 0, x = 6, y = 5, sep = '|',
- input = tmpfile, output = outfile,
+ grass.run_command('v.in.ascii', cat = 0, x = 6, y = 5, sep = 'tab',
+ input = infile, output = outfile,
columns = columns)
- grass.try_remove(tmpfile)
-
# write cmd history:
grass.vector_history(outfile)
if __name__ == "__main__":
options, flags = grass.parser()
main()
+
More information about the grass-commit
mailing list