Hi Ben,
No I haven't.
The aim of my program is to store data from shapefile to database, and the
problem is that some fields are foreign key (not mandatory), so I have to
store null value not empty string.
I could replace the empty string in null value in my program before store
them into database, but I would avoid to treat each empty string as null
value.

>From your experience, there is another way to check if the source shapefile
has '\0' in those field?




On 24 Oct 2017 21:26, "Ben Caradoc-Davies" <b...@transient.nz> wrote:

Matteo,

I suspect that QGIS converts empty strings to nulls.

Have you tried using ogr2ogr or another tool to replace empty strings with
strings starting with '\0'?

Kind regards,
Ben.


On 24/10/17 19:20, Matteo Cusmai wrote:

> Hi Ben,
> Yes, I'm using esri shape file, this is a requirement.
> However, if I access the same files with qgis, I see null values, do you
> know why?
>
> On 23 Oct 2017 23:38, "Ben Caradoc-Davies" <b...@transient.nz> wrote:
>
> Matteo,
>>
>> what is the source of your data? ESRI software and the older DBF format
>> often used in shapefiles do not natively support nulls because all fields
>> are stored as strings:
>> http://support.esri.com/en/technical-article/000005811
>> https://en.wikipedia.org/wiki/Shapefile#Data_storage
>> https://gis.stackexchange.com/questions/28411/how-to-have-a-
>> nullable-field-included-in-a-shapefile-using-the-geotools-library
>>
>> When reading a DBF file, GeoTools will treat numeric fields that are empty
>> or all whitespace or start with '*' as null, and character fields that
>> start with a null terminator byte ('\0') as null. You can see the logic
>> here:
>> https://github.com/geotools/geotools/blob/master/modules/plu
>> gin/shapefile/src/main/java/org/geotools/data/shapefile/
>> dbf/DbaseFileReader.java#L452
>>
>> Can you use a format like geopackage that has native support for nulls?
>>
>> Kind regards,
>> Ben.
>>
>> On 24/10/17 01:05, Matteo Cusmai wrote:
>>
>> Hi all,
>>> I need to read some shapefiles where some field are nillable and so they
>>> could have null value.
>>> The problem is that, I don't know why, the features has empty string
>>> where
>>> should be null.
>>>
>>> Does someone have the some problem?
>>>
>>> Regards,
>>>
>>> Matteo Cusmai
>>>
>>>
>>>
>>> ------------------------------------------------------------
>>> ------------------
>>> Check out the vibrant tech community on one of the world's most
>>> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>>>
>>>
>>>
>>> _______________________________________________
>>> GeoTools-GT2-Users mailing list
>>> GeoTools-GT2-Users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>>
>>>
>>> --
>> Ben Caradoc-Davies <b...@transient.nz>
>> Director
>> Transient Software Limited <http://transient.nz/>
>> New Zealand
>>
>>
>
-- 
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <http://transient.nz/>
New Zealand
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to