<div><br>Thank you for your help!</div>
<div> </div>
<div>Once I read your comments I tried both corrections in my code, but none of them we're sucessful. </div>
<div>Tim's idea kept the quotes at the moment I open the csv in Excel, quotues appeared at the beggining and the end of the row for Excel.</div>
<div>Joel's idea wrote just tha variable name 'filepath' and ''filename'.</div>
<div>The corrections I made were:</div>
<div>import os, csv, time, socket<br>from osgeo import ogr,gdal,osr<br>from dbf import *</div>
<div>gdal.AllRegister()<br><br>file_list = []<br>folders = None<br>for root, folders, files in os.walk( "C:\\" ):<br> file_list.extend(os.path.join(root,fi) for fi in files if fi.endswith(".shp"))<br>
<br>ofile = open('csv1.csv', "wb")<br>writer = csv.writer(open('csv2.csv', "wb"))<br>ruta = 'Ruta'<br>archivo = 'archivo'</div>
<div>prj = '.prj'</div>
<div>campos = [ruta,archivo,prj]<br>writer.writerow(campos)<br>for row, filepath in enumerate(file_list, start=1): <br> (ruta, filename) = os.path.split(filepath) </div>
<div> n = os.path.splitext(filepath)<br> p = n[0]+'.prj'<br> filepath = ''+filepath+''<br> filename = ''+filename+''</div>
<div> if os.path.exists(p):<br> prj_text = open(p, 'r').read()<br> prjtext = ''+prj_text+''<br> aRow= [ filepath, filename, 1, ]<br> writer.writerow(aRow) <br> else:<br>
no_prj = 'Sin prj, no se puede determinar la proyeccion'<br> aRow1= [ filepath, filename,0]<br> writer.writerow(aRow1)</div>
<div>print "El archivo esta listo"</div>
<div> </div>
<div> </div>
<div> </div>
<div class="gmail_quote">2011/3/11 Tim Golden <span dir="ltr"><<a href="mailto:mail@timgolden.me.uk" target="_blank">mail@timgolden.me.uk</a>></span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>On 11/03/2011 8:59 PM, Susana Iraiis Delgado Rodriguez wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hello list!!<br><br>I'm trying to write a CSV file to work it with Excel. My python script is<br>working, the issue is: when I import the file from excel the data comes with<br>
quotes at the beginnig and ending of the row. I don't want to have these<br>quotes. What is wrong with my code?<br></blockquote><br></div>Essentially, the work is being done twice.<br>The .writerow method expects a list which it will<br>
convert into a quoted, comma-separated string. You're<br>giving it a list whose one element is a quoted, comma-separated<br>string.<br><br>Just pass it a list instead:<br><br>writer.writerow (['Ruta', 'Archivo', '.prj'])<br>
...<br>writer.writerow ([filepath, filename, 1])<br><br>(BTW, my naive knowledge of Spanish suggests that you're confusing<br>the two identical-sounding English words: "root" -> "raiz" and<br>"route" -> "ruta").<br>
<br>TJG<br></blockquote></div><br>