This is automatic:

db[csv_data].import_from_csv_file(open('filename.csv'))



On Wednesday, 3 April 2013 16:40:01 UTC-5, David S wrote:
>
> I'm very new to web2py and python in general but have a bit of knowledge 
> when it comes to C/C++. 
>
> I've got a db setup which needs to pull data from a row in a .csv file and 
> put each column in the .csv into the corresponding column in the db. Rather 
> than doing this explicitly (there's ~40 columns), I'd like to have each 
> iteration of the for loop correspond to one of the columns. Here's what 
> I've got so far:
>
> for lines in import_data:
>                     info = lines.split(',')
>                     field_name = 'field1'
>                     db[csv_data].insert(**{field_name:info})
>
> The above puts all the data in 'field1' and not into separate columns, 
> close but not quite. I'm thinking some sort of select from the db might 
> work. Any ideas or links which might help?
>
> Thanks,
> David
>

-- 

--- 
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/groups/opt_out.


Reply via email to