Open GoogleCodeExporter opened 8 years ago
Attached is a quick test script to show that current 'D' handling is broken for
read/edit/write. This script writes a date value, opens for edit and saves to a
new file, then re-opens to print the values (which should be identical).
{{{$ python testcase.py
testing
records: [['first record', [2012, 2, 18]]]
testing_edited
records: [['first record', '[2012, 2']]
}}}
Original comment by david.ri...@myotisoft.com
on 25 Feb 2012 at 10:50
Attachments:
The attached, improved patch handles null values properly, by coercing between
Python None and Shapefile '0' for null date. It also accepts the literal string
YYYYMMDD format.
Attached test case shows it working with datetime.datetime, None, and string
literal.
{{{
$ python testcase.py
testing
fields: [('DeletionFlag', 'C', 1, 0), ['DESC', 'C', 20, 0], ['DATE', 'D', 8, 0]]
record count: 2
records: [['first record', datetime.date(2012, 2, 25)], ['record null date',
None]]
testing_edited
fields: [('DeletionFlag', 'C', 1, 0), ['DESC', 'C', 20, 0], ['DATE', 'D', 8, 0]]
record count: 3
records: [['first record', datetime.date(2012, 2, 25)], ['record null date',
None], ['record string literal', datetime.date(2012, 12, 31)]]
}}}
Original comment by david.ri...@myotisoft.com
on 25 Feb 2012 at 11:15
Attachments:
Original comment by jlawh...@gmail.com
on 28 Feb 2012 at 5:24
Hi guys, I am trying to write shapefile adding a Date field, but when I use a
python datetime object the field get recorded as (i.e. 0000/20/14) (note that
is 2014-the year) not the right date I chose, but strangely if I add the first
record as a string, let's say '20140328' the others records become the correct
datetime value I expected.
pyshp version is 1.2.0
Any clue?
Thanks in advance
Original comment by andrefel...@gmail.com
on 27 Mar 2014 at 10:55
Original issue reported on code.google.com by
david.ri...@myotisoft.com
on 25 Feb 2012 at 10:29Attachments: