[Tutor] PYTHON QUOTES ISSUE

Alan Gauld alan.gauld at btinternet.com
Thu Oct 7 18:31:05 CEST 2010


"Susana Iraiis Delgado Rodriguez" <susana.delgado_s at utzmg.edu.mx> 
wrote

> How can I write a statement to execute the following:
> C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr 
> R1G-GEODESIA.shp -where
> "LAYER = 'R1G-GEODESIA'" tapalpa_05_plani_point.dbf,
> I want my uotput to look like this.

erm, like what? The command string above?
So where is this output coming from?
Or are you talking about the output from the command?

> Instead I'm getting this
> C:/Archivos de programa/FWTools2.4.7/bin/ogr2ogr
> T21-PUENTES.shp -where LAYER=+line tapalpa_05_plani_line.shp

The difference is that you seem to be getting +line as a literal
string instead of the variables value. Is that the problem?


> In miy code line is a string given by the user:
>
> for line in open("unico.txt", "r").readlines():

You donlt need the readlines you can iterate over the open
file.


>     p = subprocess.Popen(['C:/Archivos de
> programa/FWTools2.4.7/bin/ogr2ogr', line+'.shp', '-where', 
> "LAYER='line'",
> b+'.shp'])

Notice that you have quotes around the line following LAYER=

> Any suggestions?

remove the quotes? And shift the double quotes after the = sign.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list