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

DbfReader throws error when trying to parse NULL Date fields #61

Open
kyleeinspahr opened this issue Nov 1, 2024 · 1 comment
Open
Labels
more details needed Unable to investigate further without additional information

Comments

@kyleeinspahr
Copy link

When evaluating the DbfReader Enumerable of a shapefile that has a Date column with NULL values, it throws the following error:
The DateTime represented by the string '00000000' is not supported in calendar 'System.Globalization.GregorianCalendar'.

Before that, I examined the Fields collection and it even reports that the Value is null:
image

Here is a file that shows the issue
ShapefileWithNULLDate.zip

@KubaSzostak
Copy link
Member

Hi @kyleeinspahr, I checked the ShapefileWithNULLDate.shp file using following code and everything works fine. Can you provide a sample code that demonstrates the issue?

var shpPath = TestShapefiles.PathTo("Issues/061/ShapefileWithNULLDate.shp");
using var shpReader = Shapefile.OpenRead(shpPath);

while (shpReader.Read())
{
    var smapleId = shpReader.Fields["SAMPLEID"].Value ?? "<null>";
    var eventDate = shpReader.Fields["EVENT_DATE"].Value ?? "<null>";
    Console.WriteLine($"SAMPLEID: {smapleId},   EVENT_DATE: {eventDate}");
}

Output:

SAMPLEID: 1,   EVENT_DATE: <null>
SAMPLEID: 2,   EVENT_DATE: <null>
SAMPLEID: 3,   EVENT_DATE: <null>
SAMPLEID: 4,   EVENT_DATE: <null>
SAMPLEID: 5,   EVENT_DATE: <null>

@KubaSzostak KubaSzostak added the more details needed Unable to investigate further without additional information label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more details needed Unable to investigate further without additional information
Projects
None yet
Development

No branches or pull requests

2 participants