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

Incorrect read some field with \x00 contains #1

Open
tonal opened this issue Jul 2, 2010 · 0 comments
Open

Incorrect read some field with \x00 contains #1

tonal opened this issue Jul 2, 2010 · 0 comments

Comments

@tonal
Copy link

tonal commented Jul 2, 2010

I have problem with read old-generated dbf-file.
Some empty char field contains strange data.
For example, field C 15 have date:
\x20\x20\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20

Path for correct this error:
diff --git a/ydbf/reader.py b/ydbf/reader.py
index 54d7d5e..f6a2a42 100644
--- a/ydbf/reader.py
+++ b/ydbf/reader.py
@@ -260,7 +260,7 @@ class YDbfReader(object):
# deleted record
continue
try:
- yield dict((name, conv(val.rstrip('\x00'), size, dec))
+ yield dict((name, conv(val.split('\x00', 1)[0], size, dec))
for (conv, name, size, dec), val
in izip(converters, record)
if (name != '_deletion_flag' or show_deleted))

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

1 participant