I do not know but you can try from the web2py shell

improt csv
reader = csv.reader(open(filename, "rb"), delimiter=";")
for (k,row) in enumerate(reader):
    if k==0:
        keys=dict([(i,h.split('.')[1]) for (i,h) in enumerate(row)])
        ncols=len(keys)
        print 'keys=',keys
    else:
        values=row
        db[tablename]insert(**dict([(keys[i],values[i]) for i in range
(ncols) and keys[i]!='id']))

and wee what fails.

On Aug 27, 9:33 am, Carlos Aboim <[email protected]> wrote:
> Hi list,
>
> I want import some data from a CSV file through admin but it keeps
> getting me error.
> CSV is made with Excel app, by default those CSV files came with semi-
> colon (;) and not coma (,)
> which I chaged outside Excel. I exported some data that was in web2py
> app and follow that format
> but still no sucess. All the lines of CSV have 5 fields (those on the
> model).
>
> One line from the data in web2py app:
> cliente.id,cliente.nome,cliente.contacto,cliente.email,cliente.morada
> 1," 1001 T-Shirts - Estampagem e Comercialização de Vestuário,
> Lda.",,<NULL>,"R. Quinta do Sales - Parque de Ateliers, 23 - Atelier
> 10 - Outurela 2790-164 CARNAXIDE "
>
> Three lines from the input data:
> cliente.id,cliente.nome,cliente.contacto,cliente.email,cliente.morada
> 1,"Amélia Rodrigues",<NULL>,"[email protected]","n.d."
> 2,"[email protected]",<NULL>,"[email protected]","n.d."
> 3,"APP",<NULL>,"[email protected]","n.d."
>
> The model only has restrictions on email field which must be 'empty'
> null or must be an email field
>
> Any help?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to