-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Add an option to return 'date' as 'string' for easy conversion to geojson. #187
Comments
I am having the same problem. @rados are you doing any manual conversion, or just using the How do you find the dates after the conversion ? Thank you ! An additional problem is if the date is empty, the Lines 1207 to 1216 in 69c60f6
|
Just pushed new commits to address this, no custom args needed. Date fields are loaded into python date objects for convenience to the user as usual, but calls to geo_interface will automatically convert them back to the original date string, so that they are directly able to be json serialized. Added tests to ensure that all geo_interface calls can be dumped to json. Based on your suggestion @cipri-tom I also ensured faulty date formats (those that end in the except clause) are converted to unicode/string. Also added better handling of possible date field null values, although the dbf format doesn't officially support date null values. Until I push a new release version, you can try it out from the latest Github version. |
Hello,
Currently I am converting shape file to a geojson. In my shape file there are dates and I have to pay special attention to convert those dates to strings in order to json-ify them. So this could be a kind of common operation and then maybe the best thing is for the pyshp library to support this inherently somehow. Probably with a kind of flag or something better. I think this could be a simple change in the Reader.__record method, 'D' case.
I am ready to help with a PR.
Thanks,
Rado
The text was updated successfully, but these errors were encountered: