[gdal-dev] Bad Date Handling

Even Rouault even.rouault at spatialys.com
Tue Apr 5 12:09:01 PDT 2016


Le mardi 05 avril 2016 20:56:07, Paul Ramsey a écrit :
> Hey all,
> 
> We've had a client working with dodgy data who would like an option to
> avoid incompatible date mangling when reading bad data. Basically, OGR
> will consume some funky dates from CSV and Excel, like 0000/00/00, but
> it will NULL out others, like 1971/34/34. The net result is that, when
> the data are written out to PgSQL, is some null values, and other
> values that get converted to things PgSQL cannot consume (0000/00/00
> becomes 2000/00/00 and PgSQL then errors out on that).
> They'd like to just coerce *all* invalid dates to NULL,
> 
> I've done a small patch that does that, in the presence of a config
> flag, any thoughts on if it's acceptable?

Paul,

Why not rather improving the datetime parser to reject invalid dates like 
0000/00/00 ? In OGRParseDate() in ogr/ogrutils.cpp. That way that would solve 
the issue not only for Postgres output, but for all other drivers.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list