Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record Alignment Issue #66

Closed
micahcochran opened this issue Aug 23, 2016 · 2 comments
Closed

Record Alignment Issue #66

micahcochran opened this issue Aug 23, 2016 · 2 comments

Comments

@micahcochran
Copy link
Contributor

micahcochran commented Aug 23, 2016

Setup code

>>> import shapefile
>>> sf = shapefile.Reader("shapefiles/blockgroups")
>>> records = sf.records()

Record Alignment issue in pyshp version 1.2.9.

From the doctests
"Let's read the blockgroup key and the population for the 4th blockgroup:"

    >>> records[3][1:3]
    ['060750601001', 4715]

pyshp version 1.2.3, Python 2.7

In [9]: records[3][1:3]
Out[9]: [u'060750601001', 4715]

pyshp version 1.2.9, Python 2.7.12

In [15]: records[3][5:7]
Out[15]: ('060750601001', '     4715')

pyshp version 1.2.9, Python 3.5.2
(Each subsequent record has move the fields over by 1 value.)

In [5]: records[3][5:7]
Out[5]: (b'060750601001', b'     4715')

In [10]: records[4][6:8]
Out[10]: (b'060750102001', b'      473')

In [11]: records[5][7:9]
Out[11]: (b'060750126001', b'     1137')

The length of sf.records() has changed...

That issue could be explained by the record alignment issue.

In all versions tests this works...

>>> sf.numRecords
663

pyshp 1.2.3

>>> len(records)
663

pyshp 1.2.9

>>> len(records)
678

There are a total of five (5) failing tests. This could solve one (1) of those failing tests.

EDIT Additional Info:

The "DeletionFlag" field is being put in the output of the records function caused by PR #62 (@karimbahgat). The record function works fine.

For instance:
pyshp 1.2.3, Python 2.7

In [35]: records[0][:5]
Out[35]: [0.96761, u'060750179029', 4531, 4682.7, 970]

pyshp 1.2.9, Python 2.7

In [49]: records[0][:5]
Out[49]: (' ', '           0.96761', '060750179029', '     4531', '    4682.7')
@micahcochran micahcochran changed the title Tests Failing Record Alignment Issue Aug 23, 2016
@karimbahgat
Copy link
Collaborator

My bad, forgot to check the tests worked. #67 should fix it.

karimbahgat added a commit that referenced this issue Sep 22, 2016
Reverts back to original records() method to fix issue #66
@micahcochran
Copy link
Contributor Author

PR #68 seems to have fixed this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants