tmontaigu / dbase-rs

Rust library to read & write dBase files.
MIT License
29 stars 30 forks source link

Fix None float value #4

Closed Farkal closed 5 years ago

Farkal commented 5 years ago

I added a test file, but i think we can create on big file with all type of fields and test each of them. To check if value was None i just check all char was equal to *. I think the same can be apply to Numeric and Double but perhaps it's linked with the lib encoding the value 😕

tmontaigu commented 5 years ago

Strange that "*" is used a a character to indicated null value I've only read that space where used for that, what did you use to create this file ?

Farkal commented 5 years ago

The script i put in the issue #2:

You will need to have python 3.6 and run pip install pyshp

import shapefile

writer = shapefile.Writer(shapefile.POLYGON)

writer.autoBalancer = 1

writer.field('name','C')
writer.field('money','F')

prop = {
    "name": 'myname',
    "money": None,
}

coords = [(0,0), (0,1), (1,1), (0,1), (0,0)]

writer.poly(parts=[coords])

values = list(prop.values())

writer.record(*values)

writer.save('test.shp')
tmontaigu commented 5 years ago

Ok, I created the file with the script but forgot to test the crate on it 🤔 .

I looked at the pyshp code and the same thing should be done for the FieldValue::Numeric

Farkal commented 5 years ago

I added the check and add other field types to the test. It should be ok now 😉

tmontaigu commented 5 years ago

Thanks