zhikrullah / pyshp

Automatically exported from code.google.com/p/pyshp
MIT License
0 stars 0 forks source link

Problem when using Editor to open files with a dot in their name #33

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Open a file named "a.b.shp" with the editor

What is the expected output? What do you see instead?
The file a.b.shp should be opened. But the editor class
uses:

base = os.path.splitext(shapefile)[0]
            if os.path.isfile("%s.shp" % base):
                r = Reader(base) """here"""
                Writer.__init__(self, r.shapeType)
                self._shapes = r.shapes()
                self.fields = r.fields
                self.records = r.records()

So "a.b" is sent to the reader constructor instead of "a.b.shp".

The reader constructor then uses the splitext function again and sees
it as a file named "a" with a ".b" extension, instead of a file
named "a.b" with a ".shp" extension.

A solution is to replace:
                r = Reader(base)
by
                r = Reader(shapefile)

(line 877)

Original issue reported on code.google.com by coyotte...@gmail.com on 25 Apr 2012 at 8:13

GoogleCodeExporter commented 8 years ago

Original comment by jlawh...@geospatialpython.com on 2 May 2013 at 5:03