On Wednesday, June 24, 2015 at 11:43:46 AM UTC-7, Dave S wrote:

But hey, Niphlod beat me to it.

 

> On Wednesday, June 24, 2015 at 10:28:21 AM UTC-7, goome wrote:
>>
>> Hello
>> i have a table with integer field.
>> i populated thhe db from a csv (created from other then me).
>> it sometimes has empty value for the integers fields.
>> So when i try to get a list of the records of the table, i got:
>> type 'exceptions.ValueError'> invalid literal for long() with base 10: ''
>>
>> [...] 
>>
> how to face with empty values?
>>
>>
> I think the simplest choices are probably
> *  preprocessing (for example, runnng the CSV file through sed or awk to 
> replace ',,' with ' ,-9999999,' (or other value you can recognize as 
> "illegal")
>

This is similar to Niphlod's advice.  But lacking his deeper knowledge, I'd 
be running a "cleanup job" (post-processing) on the imported data to 
convert the "illegal" values to NULL.  Probably through the scheduler.
 

> *  customizing the CSV import code to allow an empty field.
>

Or changing the field definition, perhaps to a string type, and then 
converting non-empty strings at a later time.

Or changing the validator to provide the NULL.
 
/dps

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to