Re: [web2py] How to import data from csv file in web2py for SQLite database?

2015-10-14 Thread 黄祥
another way around i think you can create a function (e.g. 
import_data_csv.py) in controller or modules and access it (web browser or 
terminal)

best regards,
stifan

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


Re: [web2py] How to import data from csv file in web2py for SQLite database?

2015-10-14 Thread Richard Vézina
:)

Richard

On Wed, Oct 14, 2015 at 3:00 PM, Dave S  wrote:

>
>
> On Wednesday, October 14, 2015 at 11:57:30 AM UTC-7, Richard wrote:
>>
>> if db(db.table.id > 0).count() == 0:
>> db.table2.import_from_csv_file(open(open('mycsv','r'))
>>
>> So it will be executed only once...
>>
>> Richard
>>
>
> You type too fast!
>
> /dps
>
>
>>
>> On Wed, Oct 14, 2015 at 10:48 AM, 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.
>>>
>>> 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+un...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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.
>

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


Re: [web2py] How to import data from csv file in web2py for SQLite database?

2015-10-14 Thread Dave S


On Wednesday, October 14, 2015 at 11:57:30 AM UTC-7, Richard wrote:
>
> if db(db.table.id > 0).count() == 0:
> db.table2.import_from_csv_file(open(open('mycsv','r'))
>
> So it will be executed only once...
>
> Richard
>

You type too fast!

/dps
 

>
> On Wed, Oct 14, 2015 at 10:48 AM, 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. 
>>
>> 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+un...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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


Re: [web2py] How to import data from csv file in web2py for SQLite database?

2015-10-14 Thread Richard Vézina
if db(db.table.id > 0).count() == 0:
db.table2.import_from_csv_file(open(open('mycsv','r'))

So it will be executed only once...

Richard

On Wed, Oct 14, 2015 at 10:48 AM, 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.
>
> 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.
>

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


[web2py] How to import data from csv file in web2py for SQLite database?

2015-10-14 Thread Prasad M
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. 

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.