Hello Anthony, Thanks for your reply.
I exported the CSV after adding some records, as you suggested, and I see 
no difference in the format. I tried to change the format several times but 
I can't import it. I either get the None records or an error depending on 
how I tried to modify the format.

On Friday, February 26, 2016 at 8:56:07 PM UTC+8, Anthony wrote:
>
> Maybe manually enter a few records, export to CSV, and inspect the 
> exported file to make sure your imported file has everything in the proper 
> format.
>
> Anthony
>
> On Friday, February 26, 2016 at 4:46:52 AM UTC-5, Joe wrote:
>>
>> I tried to import a CSV file  but all the values are None.
>>
>> This is what I did:
>>
>> def index():
>>     if request.vars.csvfile != None:
>>         table = db[request.vars.table]
>>         file = request.vars.csvfile.file
>>         table.import_from_csv_file(file)
>>     return dict()
>>
>> My tables look like this:
>>
>> db.define_table('animation',
>>     Field('activity', widget=SQLFORM.widgets.radio.widget, 
>> requires=IS_IN_SET({'Co-prod', 'Buyer','Sales', 'Producer', 'Director'})), 
>> Field('business', widget=SQLFORM.widgets.radio.widget, 
>> requires=IS_IN_SET({'Distribution', 'Broadcaster','Production', 'Internet', 
>> 'Financing', 'MNO', 'Press'})), Field('company', 'string', 
>> requires=[IS_NOT_EMPTY()]), Field('country', requires=[IS_NOT_EMPTY()]), 
>> Field('email', requires=[IS_NOT_EMPTY(), IS_EMAIL()]), Field('first_name', 
>> 'string',requires=IS_NOT_EMPTY()), Field('last_name', 
>> 'string',requires=IS_NOT_EMPTY()), Field('position_title', 
>> 'string',requires=IS_NOT_EMPTY()), Field('website', 
>> 'string',requires=[IS_NOT_EMPTY(), IS_URL]), Field('date_made', 'datetime', 
>> default = request.now, writable=False, readable=False, requires = 
>> IS_DATE(format=('%d-%m-%Y'))))
>>
>> My view:
>> {{extend 'layout.html'}}
>>
>> {{=FORM(INPUT(_type='file',_name='csvfile'),INPUT(_type='hidden',_value='animation',_name='table'),INPUT(_type='submit',_value='Upload'))}}
>>
>> The CSV file has the same headers as the table names. The CSV is 
>> imported, the length of the rows in the database are the same as in the CSV 
>> file but the records are all None.
>> What I want to do is to be able to import CSV files to this db as well as 
>> input values manually using a form. This is why I am using a radio.widget.
>> What am I doing wrong?
>>
>> Thanks.
>>
>> Joe
>>
>

-- 
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