On Wednesday, October 14, 2015 at 11:03:01 AM UTC-7, Prasad M wrote:
>
> I am trying to import data from csv in web2py's SQlite databae. 
> 1) First I have defined table in database.
> 2) I wrote db.table2.import_from_csv_file(open(open('mycsv','r')) this 
> line . 
> Both steps are in Model. 
>
> But while displaying data from the same table I am getting repeated rows 
> at each refresh of the page. It means each time file appends data to table. 
>

Models get run every time the page is displayed (including refreshes).  So 
you are doing the import (step 2) ) each time you refresh.  You either need 
logic to only run the import once, or you need to remove the import from 
the model.

What are you trying to do with the import?  One use is to initialize the 
table with known data when installing it in a new host.  In that case, the 
logic could be something like db().select(db.table2.id > 0).count()  > 0.

/dps


> So my question is how to solve this issue? 
> Exactly where to write code for import data from csv to table? This is my 
> query. 
> I am trying to get this from 2 days.
> Please try to answer. 
> Thank you in advanced !!!!
>
>

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