[web2py] Re: import_from_csv_file and auth.signature

2020-07-24 Thread David Orme
Well now that is embarrassing. Thanks! For reference, this was my recipe to put at the top of a file that is going to populate multiple tables: if db(db.auth_user).count() == 0: #Bulk load account admin_user_id = db.auth_user.insert(first_name='Bulk uploader') else: admin_user_id = d

[web2py] Re: import_from_csv_file and auth.signature

2020-07-24 Thread villas
Did you try... db.locations.created_by.default = 1 # or whateverdb.locations.modified_by.update = 1 prior to: import_from_csv_file -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issu

[web2py] Re: import_from_csv_file: how to map columns

2016-01-13 Thread goome
Thanks for your help! Il giorno mercoledì 13 gennaio 2016 16:38:12 UTC+1, Anthony ha scritto: > > I think you'll have to manually change the column names in the file, > either by hand or via Python code. > > Anthony > > On Wednesday, January 13, 2016 at 7:33:20 AM UTC-5, goome wrote: >> >> Hi >>

[web2py] Re: import_from_csv_file: how to map columns

2016-01-13 Thread Anthony
I think you'll have to manually change the column names in the file, either by hand or via Python code. Anthony On Wednesday, January 13, 2016 at 7:33:20 AM UTC-5, goome wrote: > > Hi > i created i table definition in db.py by using csvstudio.py, but i cannot > load the values through db.table.

Re: [web2py] Re: import_from_csv_file

2016-01-11 Thread Marcello Console
Thank you 2016-01-11 20:25 GMT+01:00, Anthony : > db.mytable.import_from_csv(..., unique='my_unique_column') > > will do an update instead of an insert if the value of the > "my_unique_column" field matches that of an existing record in the > database. > > Anthony > > On Monday, January 11, 20

[web2py] Re: import_from_csv_file

2016-01-11 Thread Anthony
db.mytable.import_from_csv(..., unique='my_unique_column') will do an update instead of an insert if the value of the "my_unique_column" field matches that of an existing record in the database. Anthony On Monday, January 11, 2016 at 12:07:55 PM UTC-5, goome wrote: > > hi > Does import_from_csv

[web2py] Re: import_from_csv_file and id_map={}

2015-08-26 Thread Massimo Di Pierro
yes On Tuesday, 25 August 2015 18:02:40 UTC-5, Mark Li wrote: > > Is id_map still necessary to preserver references when using > import_form_csv_file function? > > I read this in the docs ( > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--all-tables-at-once- > )

[web2py] Re: import_from_csv_file and id_map={}

2015-08-25 Thread Mark Li
Is id_map still necessary to preserver references when using import_form_csv_file function? I read this in the docs ( http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--all-tables-at-once- ): "When importing, the new records will be appended to the database if it i

[web2py] Re: import_from_csv_file and id_map={}

2015-03-17 Thread Tom Clerckx
Thanks. I will try to make some time and contribute in that way. Note: You may want to update the link to your profile on http://web2py.com/init/default/who --> it results in a page not found. Best regards, Tom. On Wednesday, March 11, 2015 at 7:07:04 PM UTC+1, Tom Clerckx wrote: > > I recentl

[web2py] Re: import_from_csv_file and id_map={}

2015-03-12 Thread Massimo Di Pierro
I agree. The problem is lack of manpower. If you send me a paragraph I will include it in the docs. On Wednesday, 11 March 2015 13:07:04 UTC-5, Tom Clerckx wrote: > > I recently learned (by searching through the google-group) the usefulness > of the id_map={} parameter in the db.import_from_csv

[web2py] Re: import_from_csv_file and unique

2014-08-29 Thread Derek
I think it should, but I'm assuming that's not how it is in practice. On Thursday, August 28, 2014 11:55:26 PM UTC-7, lyn2py wrote: > > Thanks Derek. If the "uuid" field were specified, shouldn't the specified > field be used, the way a uuid field is used, to de-duplicate records? -- Resources:

[web2py] Re: import_from_csv_file and unique

2014-08-28 Thread lyn2py
Thanks Derek. If the "uuid" field were specified, shouldn't the specified field be used, the way a uuid field is used, to de-duplicate records? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/w

[web2py] Re: import_from_csv_file and unique

2014-08-28 Thread Derek
>From the documentation: When importing, the new records will be appended to the database if it is not empty. In general the new imported records will not have the same record id as the original (saved) records but web2py will restore references so they are not broken, even if the id values may

[web2py] Re: import_from_csv_file troubles

2012-06-20 Thread Niphlod
book say this. db.person.import_from_csv_file(open('test.csv', 'r')) why do you use a different syntax ? BTW: you'd need to delete the table first, or you'll append to existent records in the database the ones in the csv file. On Wednesday, June 20, 2012 3:55:26 PM UTC+2, joe wrote: > > I w

[web2py] Re: import_from_csv_file broken

2012-02-16 Thread Simon Lukell
not sure if there is a difference in the resulting file, but I usually use db.category.export_to_csv_file(open(...)) On Feb 16, 3:24 pm, Richard Penman wrote: > I exported a table from sqlite with: > open(filename, 'w').write(str(db(db.category.id).select())) > > Output file looks as expected. >

Re: [web2py] Re: import_from_csv_file broken

2012-02-16 Thread Ron McOuat
Looked in the DAL section of the manual, looks like you need to open the file and supply the File object as the parameter to db.table.import_from_csv(...) You can serialize a single table in CSV and store it in a file "test.csv": 1. >>> open('test.csv', 'w').write(str(db(db.person.id).select(

Re: [web2py] Re: import_from_csv_file broken

2012-02-15 Thread Richard Baron Penman
did it from controller. And not a rollback because the data was inserted, just the fields are NULL. On Thu, Feb 16, 2012 at 4:52 PM, Ron McOuat wrote: > If you did this from a shell using the -S and -M web2py.py options then > the code must do a db.commit() as part of the program flow. A reques

[web2py] Re: import_from_csv_file broken

2012-02-15 Thread Ron McOuat
If you did this from a shell using the -S and -M web2py.py options then the code must do a db.commit() as part of the program flow. A request through the web server has commit and rollback operations embedded in the request processing transaction management. Ron

[web2py] Re: import_from_csv_file problem with reference fields with 1.99.2?

2011-11-22 Thread Zphen
I'm interested to learn the answer to this -I tried to export from SQLite and import into a MySQL database, but the references got messed up no matter what I tried... On Nov 22, 4:36 am, David Manns wrote: > In my application which is hosted on GAE I have backup/restore > functions which use expo

Re: [web2py] Re: import_from_csv_file looses reference, if it references the record it belongs to

2010-09-26 Thread Thadeus Burgess
A little something like this I use a much more complex version of this for migration. open csv records = dict() for line in csv: parse if new table if yes continue parse table field names if yes continue if tablename == 'asdf': asdf = line but [delete id, set reference records t

[web2py] Re: import_from_csv_file looses reference, if it references the record it belongs to

2010-09-25 Thread mdipierro
This is a good idea. This could also be used to fix 'list:reference' On Sep 26, 1:26 am, Thadeus Burgess wrote: > Write a custom csv importer. use the code in gluon as an example for parsing. > > During the initial import, set the reference to None. While importing, > keep a dictionary in memory

Re: [web2py] Re: import_from_csv_file looses reference, if it references the record it belongs to

2010-09-25 Thread Thadeus Burgess
Write a custom csv importer. use the code in gluon as an example for parsing. During the initial import, set the reference to None. While importing, keep a dictionary in memory that can hold all needed references to a record. After import, commit, and then go through your dictionary fixing all of

[web2py] Re: import_from_csv_file looses reference, if it references the record it belongs to

2010-09-25 Thread mdipierro
There is no way to do this. When you import the first record, the second does not exist yet therefore the reference cannot be adjusted by web2py. This is why self references are never a good idea. Use a link table instead. On Sep 25, 2:19 pm, Jurgis Pralgauskis wrote: > Hello, > > I have Topics T