[web2py] unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field

167 views
Skip to first unread message

Richard Vézina

unread,
Mar 27, 2012, 3:20:27 PM3/27/12
to web2py-users
Hello,

Is it possible the table csv import method be broken?

When I use list:reference type field I can't import back a exported CSV with the appadmin.

I don't understand where the None value could come from...

When I try to implement my own csv import function base on this thread : https://groups.google.com/forum/?fromgroups#!topic/web2py/lDi0lLK_Wm0

That work fine, until I try to import data with list:reference type field (|id| or |id|id|, etc.)

I get this traceback :

for v in bar_decode_string(value)]
TypeError: 'NoneType' object is unsubscriptable

Function argument list

(field=<gluon.dal.Field object>, value='|35|1|', id_map=None)

Code listing
5683.
5684.
5685.
5686.
5687.
5688.

5689.
5690.
5691.
5692.
            elif field.type.startswith('list:string'):
value = bar_decode_string(value)
elif field.type.startswith(list_reference_s):
ref_table = field.type[len(list_reference_s):].strip()
value = [id_map[ref_table][int(v)] \
for v in bar_decode_string(value)]

elif field.type.startswith('list:'):
value = bar_decode_integer(value)
elif id_map and field.type.startswith('reference'):
try:
Variables
global bar_decode_string <function bar_decode_string>
value '|35|1|'
v '35'

What is exactly id_map?

I think problem is coming from there...

Thanks

Richard

Richard

unread,
Mar 27, 2012, 3:45:50 PM3/27/12
to web...@googlegroups.com

Richard

unread,
Mar 27, 2012, 3:52:31 PM3/27/12
to web...@googlegroups.com
This one to : https://groups.google.com/forum/?fromgroups#!topic/web2py/H_QqV2g8IgQ

I experimented the problem with 1.99.4 and 1.99.7

What I understand so far is that id_map get None by default, so when it get here :

[id_map[ref_table][int(v)] \
                             for v in bar_decode_string('|35|1|')]

It clears that it will raise the exception...

I try to call my import function like this :

def import_csv(table, file):
    table.import_from_csv_file(file, id_map = {})

Noting better.

Please help.

Richard

Richard Vézina

unread,
Mar 27, 2012, 5:04:47 PM3/27/12
to web...@googlegroups.com
Same thing with trunk...

Richard

Massimo Di Pierro

unread,
Mar 28, 2012, 9:34:52 AM3/28/12
to web...@googlegroups.com
Please open a ticket.

Richard Vézina

unread,
Mar 28, 2012, 10:48:28 AM3/28/12
to web...@googlegroups.com
Done!

 Issue 738:unable to parse csv file 'NoneType' object is unsubscriptable with list:reference type field

Thanks

Richard
Reply all
Reply to author
Forward
0 new messages