My other message was incomplete, it was a mistake: This is the correct one<br><br>
<div class="gmail_quote">2010/12/7 Susana Iraiis Delgado Rodriguez <span dir="ltr">&lt;<a href="mailto:susana.delgado_s@utzmg.edu.mx">susana.delgado_s@utzmg.edu.mx</a>&gt;</span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>I make a script to redirect a txt file from an external directory, but in this directory I don&#39;t have permission to write, just to read data. So I make this module:</div>
<div>import os, time,fnmatch<br>from xlwt import Workbook<br>from osgeo import ogr,gdal,osr<br>from dbf import *</div>
<div>gdal.AllRegister()<br>file_list = []<br>folders = None<br>for root, folders, files in os.walk( &quot;R:\\&quot; ):<br>for filename in fnmatch.filter(files, &#39;*.shp&#39;):<br>    file_list.append(os.path.join(root, filename))<br>
    wrkbk = Workbook()<br>    wksht = wrkbk.add_sheet(&#39;shp&#39;) <br>    wksht.row(0).write(0,&#39;ruta&#39;)<br>    wksht.row(0).write(1,&#39;archivo&#39;)<br>    wksht.row(0).write(2,&#39;estructura bd&#39;)<br>    for row, filepath in enumerate(file_list, start=1): <br>
        wksht.row(row).write(0, filepath)<br>        (ruta, filename) = os.path.split(filepath) <br>         wksht.row(row).write(1, filename)<br>         f = os.path.splitext(filename)<br>         t = f[0]+&#39;_bd.txt&#39;<br>
         d = n[0]+&#39;.dbf&#39;<br>         if os.path.lexists(d):<br>               filepath = &quot;C:\\Python26\\&quot;<br>               a = open (filepath +t,&quot;w+&quot;)<br>               dbf = Dbf(d,new=False)<br>
               for fldName in dbf.fieldDefs:<br>               a.write(fldName.name)<br>               a.write(&quot; || &quot;)<br>               a.write(fldName.typeCode)<br>               a.write(&quot;\n&quot;)<br>       dbf.close()<br>
   a.close()<br>   wksht.row(row).write(2, t)<br>      else:<br>              print &quot;El archivo &quot; +n[0]+&quot;.shp&quot; &quot; no tiene dbf&quot;<br>              wksht.row(row).write(10, &quot;Sin bd&quot;<br>
wrkbk.save(&#39;C:\\Python26\\biblio_shp.xls&#39;)<br></div></blockquote>
<div>When I run the script I got the next error:</div>
<div>&gt;&gt;&gt; import crawler_shp<br>Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>  File &quot;crawler_shp.py&quot;, line 105, in &lt;module&gt;<br>    dbf = Dbf(d,new=False)<br>
  File &quot;C:\Python26\lib\site-packages\dbf.py&quot;, line 125, in __init__<br>    self.stream = file(f, (&quot;r+b&quot;, &quot;rb&quot;)[bool(readOnly)])<br>IOError: [Errno 13] Permission denied: &#39;R:\\Aplicaciones\\IRISv3\\mis proyectos\<br>
\HURACAN\\BUFFER1000.dbf&#39;</div>
<div> </div>
<div>The error is pointing to a library I used to make the script run: dbf.py. in thid lines:</div>
<div>if isinstance(f, basestring):<br>            # a filename<br>            <a href="http://self.name">self.name</a> = f<br>            if new:<br>                # new table (table file must be<br>                # created or opened and truncated)<br>
                self.stream = file(f, &quot;w+b&quot;)<br>            else:<br>                # tabe file must exist<br>                self.stream = file(f, (&quot;r+b&quot;, &quot;rb&quot;)[bool(readOnly)])</div>
<div> </div>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div> </div></blockquote></div><br>