[Tutor] 'function' object has no attribute 'writer'
Peter Otten
__peter__ at web.de
Mon Sep 5 21:09:56 CEST 2011
Susana Iraiis Delgado Rodriguez wrote:
Susana, please use 4-space indents for your code samples. I've said it
before, but I think it's worthwhile repeating because it makes it much
easier to grasp the structure of a script at first sight.
> But now I get a differente error, this script is going to collect
> information from shapefiles, I asked the user where to start the search,
> the file extension, and the csv name. Now I get:
>>>> import win
>>>> Seleccione directorio donde empezar
> You chose C:/
> Escribe la extension que necesitas buscar
> Buscando archivos: .shp
> Nombre del csv a crear
> Archivo de salidad: gui.csv
> Iniciando...
> Exception in Tkinter callback
> Traceback (most recent call last):
> File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
> return self.func(*args)
> File "win.py", line 65, in boton4
> shapeData = ogr.Open(filepath)
> File "C:\Python26\lib\site-packages\osgeo\ogr.py", line 4033, in Open
> return _ogr.Open(*args, **kwargs)
> TypeError: in method 'Open', argument 1 of type 'char const *'
>
> The other part of the code is:
> from osgeo import ogr,gdal,osr
> shapeData = ogr.Open(filepath)
filepath is a unicode string, your library seems to expect byte strings.
Try converting it like so:
import sys
filesystemencoding = sys.getfilesystemencoding()
#...
shapeData = ogr.Open(filepath.encode(filesystemencoding))
More information about the Tutor
mailing list