[GRASS-user] g.rename problem with Python
RichardCooper
richtcooper at hotmail.com
Mon Nov 7 01:22:03 PST 2016
I' trying to rename a bunch of imported netCDF layers which include
periods/dots in their filenames. I can rename replacing the '.' with '_' in
the g.rename GUI module, but in Python I get the following errors.
I'd be really grateful for any advice on how to deal with the periods in the
Python script. Alternatively, I could rename before importing into GRASS...
Thanks,
Richard
My script is as follows:
from grass_session import *
...
#Rename layers replacing '.' with '_'
with open('glist_llrotate.txt') as gl:
for line in gl:
renamed = line.replace('.','_')
print 'Renamed layer:', renamed
grass.run_command('g.rename', raster = (line,renamed), overwrite =
True)
...
And the error:
WARNING: Illegal filename <cahpa.f1jan.05216.nc_remapped.nc.27
>. Character <
> not allowed.
The gllist_llrotate.txt file contains content such as:
cahpa.f1jan.05216.nc.1
cahpa.f1jan.05216.nc.10
cahpa.f1jan.05216.nc.11
cahpa.f1jan.05216.nc.12
...
GRASS version: 7.0.1svn
GRASS SVN Revision: 65041
Build Date: 2015-04-10
Build Platform: x86_64-unknown-linux-gnu
GDAL/OGR: 1.11.2
PROJ.4: 4.9.0
GEOS: 3.4.2
SQLite: 3.8.2
Python: 2.7.6
wxPython: 2.8.12.1
Platform: Linux-3.13.0-95-generic-x86_64-with-LinuxMint-17.1-rebecca
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/g-rename-problem-with-Python-tp5294558.html
Sent from the Grass - Users mailing list archive at Nabble.com.
More information about the grass-user
mailing list