Hello taserian and Antonio! Thank you both for taking the time to answer my question. With taserian's code it gives me the next output: C... ogr2ogr T21-PUENTESshp -where "LAYER=T21-PUENTES" tapalpa_05_plani_line.shp but the output I need is: C... ogr2ogr T21-PUENTESshp -where "LAYER=' T21-PUENTES' " tapalpa_05_plani_line.shp
I did the Antonio's suggested corrections, and I got the string I wanted, now the problem is that my subprocess doesn't work properly, I'll give a look and see whats wrong with it. 2010/10/7 taserian <taser...@gmail.com> > On Thu, Oct 7, 2010 at 12:48 PM, taserian <taser...@gmail.com> wrote: > >> I'm adding some line breaks to make your text a little more readable. >> >> On Thu, Oct 7, 2010 at 9:55 AM, Susana Iraiis Delgado Rodriguez < >> susana.delgad...@utzmg.edu.mx> wrote: >> >> Hello members: >>> >>> 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. >>> 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 >>> >> >> >>> In miy code line is a string given by the user: >>> >>> for line in open("unico.txt", "r").readlines(): >>> p = subprocess.Popen(['C:/Archivos de >>> programa/FWTools2.4.7/bin/ogr2ogr', line+'.shp', '-where', "LAYER='line'", >>> b+'.shp']) >>> >>> Any suggestions? >>> >> >> Without knowing specifics about what the subprocess.Popen function is >> expecting as parameters, I can only speculate, but it seems that the >> following *might* work (for extremely generous values of "*might*"): >> >> for line in open("unico.txt", "r").readlines(): >> p = subprocess.Popen(['C:/Archivos de >> programa/FWTools2.4.7/bin/ogr2ogr', line+'.shp', '-where', "\"LAYER='" + >> line + "'\"", b+'.shp']) >> >> Details about where the changes are: >> "\"LAYER='" + line + "'\"" >> > > Begin corrections (corrections start with a *) > > Quote to begin the literal: " >> An escaped quote (1) so that there's a quote inside the literal: \" >> Some of the text that's meant to be unchanging: LAYER= >> > *Single Quote (2) to be included in the literal (which doesn't need to be > escaped): ' > >> Close Quote: " >> > Add the content of the variable "line" from the unico.txt file: + line + >> > *Add another literal, composed of the single quote that closes (2) above, > then the closing escaped quote to close (1) : "'\"" > > >> >> See if this works, and let us know how it turns out. >> >> Antonio Rodriguez >> > > End of corrections. > > Antonio Rodriguez >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor