[web2py] import from csv
with this db setup: db.define_table('station', Field('name'), Field('location'), Field('file', 'upload') db.define_table('records', ('station_id', db.station), Field('col1'), Field('col2')) col1-col2 are from file uploaded i want to have a controller that takes this csv file and imports the data, assigning also a station_id value with a form.process().accepted i can handle the file, but with which method should be better to import? db import from csv can have custom columns layout such as SQLFORM.grid() for example? thanks -- --- 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.
Re: [web2py] cannot redefine field
you are right, forgotten about the .requires part :/ thanks! On Sunday, July 21, 2013 9:32:15 PM UTC+3, Jonathan Lundell wrote: > > On 21 Jul 2013, at 11:28 AM, "K. Antonis Tzorvas" > > > wrote: > > db.define_table('station', > Field('name'), > Field('country', 'string'), > Field('city', 'string'), > Field('records_file', 'upload'), > format='%(name)s', > migrate=False) > > db.station.name.requires = IS_NOT_IN_DB(db, 'station.name') > > i had this one > and i want to add an extra line > db.station.records_file = IS_NOT_EMPTY() > > but i am getting this erro: > >> SyntaxError: Object exists and cannot be redefined: records_file >> >> > any idea? > > > db.station.records_file.requires = IS_NOT_EMPTY() > > -- --- 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.
[web2py] cannot redefine field
db.define_table('station', Field('name'), Field('country', 'string'), Field('city', 'string'), Field('records_file', 'upload'), format='%(name)s', migrate=False) db.station.name.requires = IS_NOT_IN_DB(db, 'station.name') i had this one and i want to add an extra line db.station.records_file = IS_NOT_EMPTY() but i am getting this erro: > SyntaxError: Object exists and cannot be redefined: records_file > > any idea? -- --- 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.
[web2py] define model, required only one from two fields
i have a table: db.define_table('records', Field('file', 'upload'), Field('url', 'string')) and i want either "file" or "url" to be filled, cases that both are empty or filled should not pass. any idea on how to implement this one? -- --- 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.
[web2py] Re: Web2Py cannot import module matplotlib
all operations are noticeably very slow, I haven't changed anything from the setup, any idea on what to look for? with the same app on pythonanywhere, everything runs faster On Saturday, July 20, 2013 11:53:36 AM UTC+3, K. Antonis Tzorvas wrote: > > I solved this problem by adding > import os > import tempfile > os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp() > > before the import matplotlib and it's running, but i had problems with the > plotting due to headless environment i was getting this error from py-Tk: > *"no display name and $DISPLAY environment variable"*I Solved this by > adding > import matplotlib > matplotlib.use('Agg') > import matplotlib.pyplot as plt > > I've seen your scripts for setting up web2py in such a different ways > (with or without redmine/postgresql etc) and i liked this logic, i will go > and setup a standard development environment in my remote machine/server so > to avoid conflicts when uploading the application in a different > environment -- if there is any suggestion, it would be more than pleasantly > to hear it! > > thanks for your great work! > > On Saturday, July 20, 2013 10:42:12 AM UTC+3, Massimo Di Pierro wrote: >> >> Look into this. When you import matplotlib it attempts to read(write?) >> into the MPLCONFIGDIR. If it does not exist for the user or the user >> (www-data) does not have read/write permission it fails. >> >> On Friday, 19 July 2013 20:45:28 UTC-5, K. Antonis Tzorvas wrote: >>> >>> I've used this script >>> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh >>> >>> and the problem is that i cannot import matplotlib in web2py (although >>> it did import numpy) >>> if i try to run /home/www-data/web2py/web2py.py on another port then >>> there is no problem with the import and the application is running fine >>> >>> any idea? >>> thanks >>> >> -- --- 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.
[web2py] Re: Web2Py cannot import module matplotlib
I solved this problem by adding import os import tempfile os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp() before the import matplotlib and it's running, but i had problems with the plotting due to headless environment i was getting this error from py-Tk: *"no display name and $DISPLAY environment variable"*I Solved this by adding import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt I've seen your scripts for setting up web2py in such a different ways (with or without redmine/postgresql etc) and i liked this logic, i will go and setup a standard development environment in my remote machine/server so to avoid conflicts when uploading the application in a different environment -- if there is any suggestion, it would be more than pleasantly to hear it! thanks for your great work! On Saturday, July 20, 2013 10:42:12 AM UTC+3, Massimo Di Pierro wrote: > > Look into this. When you import matplotlib it attempts to read(write?) > into the MPLCONFIGDIR. If it does not exist for the user or the user > (www-data) does not have read/write permission it fails. > > On Friday, 19 July 2013 20:45:28 UTC-5, K. Antonis Tzorvas wrote: >> >> I've used this script >> https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh >> >> and the problem is that i cannot import matplotlib in web2py (although it >> did import numpy) >> if i try to run /home/www-data/web2py/web2py.py on another port then >> there is no problem with the import and the application is running fine >> >> any idea? >> thanks >> > -- --- 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.
[web2py] Web2Py cannot import module matplotlib
I've used this script https://github.com/web2py/web2py/blob/master/scripts/setup-web2py-nginx-uwsgi-ubuntu.sh and the problem is that i cannot import matplotlib in web2py (although it did import numpy) if i try to run /home/www-data/web2py/web2py.py on another port then there is no problem with the import and the application is running fine any idea? thanks -- --- 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.