CSV Import/Export issues

26 views
Skip to first unread message

Fran

unread,
Jan 11, 2009, 6:14:17 AM1/11/09
to web2py Web Framework
I am getting problems with CSV Import:
'unable to parse csv file'
This is with a file which has been exported via appadmin, so should
contain all the right fields.
Some tables import their dumps fine.

This seems to be caused by this model definition:
SQLField('type', db.or_organisation_type)
With this validator:
db['%s' % table].type.requires=IS_NULL_OR(IS_IN_DB
(db,'or_organisation_type.id','or_organisation_type.name'))

I have <NULL> showing in the field in the CSV.

If I change that then the next error I get is with the datetime field:
SQLField('modified_on','datetime',default=now)
This is saved as: 11/01/2009 10:26:55
But gives a Traceback:
File "C:\Bin\web2py\gluon\sql.py", line 1368, in __getitem__
y,m,d=[int(x) for x in str(value)[:10].strip().split('-')]
ValueError: invalid literal for int() with base 10: '11/01/2009'


I went back to do some tests on earlier versions of Web2Py & found
that all versions (back to 1.54 at least) on both win & src versions
(Python 2.54. for the latter) fail to even Export with the Examples
application...I try creating Users or Products & the export Tracesback
with:
File "/Users/massimodipierro/web2py/gluon/sql.py", line 337, in
__getitem__
KeyError: 'users'


Thanks for pointers on best way forward :)

F

Fran

unread,
Jan 11, 2009, 6:28:22 AM1/11/09
to web2py Web Framework
On Jan 11, 11:14 am, Fran <francisb...@googlemail.com> wrote:
> I am getting problems with CSV Import:

Another issue I'm seeing is that the Validators aren't applied:
I have a uuid field (e.g. in my gis_projection table):
SQLField('uuid',length=64,default=uuid.uuid4())
db['%s' % table].uuid.requires=IS_NOT_IN_DB(db,'gis_projection.uuid')

However when I import the export then I end up with multiple records
with the same UUID!

Strangely enough I also see the identical UUIDs for the 2 default
records I create during my app intialisation with consecutive:
db['%s' % table].insert(...)
(I'm aware the time must be almost identical & this is one of the
inputs for uuid, but we shouldn't be able to create identical
records...)

More thanks :)
Fran.

Fran

unread,
Jan 11, 2009, 6:30:47 AM1/11/09
to web2py Web Framework
On Jan 11, 11:28 am, Fran <francisb...@googlemail.com> wrote:
> Strangely enough I also see the identical UUIDs for the 2 default
> records I create during my app intialisation with consecutive:
> db['%s' % table].insert(...)
> (I'm aware the time must be almost identical & this is one of the
> inputs for uuid, but we shouldn't be able to create identical
> records...)

I fixed this part by changing to:
SQLField('uuid',length=64)
& doing the uuid.uuid4() within each record insertion instead of as
the default.

F

Jonathan Benn

unread,
Jan 12, 2009, 5:47:58 AM1/12/09
to web2py Web Framework
Hi Fran,


Which platform are you running web2py on? Using which database?

I've found that CSV import does not work on Google App Engine.


--Jonathan

Fran

unread,
Jan 12, 2009, 7:37:29 AM1/12/09
to web2py Web Framework
On Jan 12, 10:47 am, Jonathan Benn <jonathan.b...@gmail.com> wrote:
> Which platform are you running web2py on? Using which database?
> I've found that CSV import does not work on Google App Engine.

Windows XP, sqlite

F

mdipierro

unread,
Jan 12, 2009, 10:25:03 AM1/12/09
to web2py Web Framework
Can you give an example of import/export that does not work on GAE?
Granted you cannot import in 1.55 data exported with 1.53 or earlier
because of incompatible formats.

Massimo
Reply all
Reply to author
Forward
0 new messages