[web2py:19391] unable to parse csv file
Hi, I'm using the last web2py release on localhost with python-2.5.4 on a LFS based system. I'm trying to import a CSV file through the web2py interface, I have tried several CVS output,but everytime,I've got the same error which is "unable to parse csv file" Here is the sqlite database created with web2py : db.py : #!/usr/bin/python # -*- coding: utf-8 -*- db = SQLDB('sqlite://bddpackages.db') db.define_table("packages", SQLField("nom","string",length=32,notnull=True,default=""), SQLField ("description","string",length=128,notnull=True,default=""), SQLField("url","string",length=64,notnull=True,default=""), SQLField("packager","string",length=64,default=""), SQLField("categorie","string",length=32,default="")) Here is the CSV file that I have made (a package database), it's the output of (prt-get is a package manager) : $ prt-get printf "\"\",\"%n\",\"%d\",\"%u\",\"%P\",\"cat\"\n" >> /tmp/ db_packages.csv Yes, the first line of this file is written by myself (I saw that line when I have exported a little database made by hand) packages.id,packages.nom,packages.description,packages.url,packages.packager,packages.categorie "","AfterStep","Gestionnaire de fenêtres","http:// www.afterstep.org/","geanbrun","cat" "","ICU","International Components for Unicode for C","http://www.icu- project.org/","","cat" "","LibVNCServer","seveur VNC","http:// libvncserver.sourceforge.net/","floreal.c at orange dot fr","cat" "","MesaLib","OpenGL compatible 3-D graphics library","http:// mesa3d.sourceforge.net","Thierry Nuttens, thierryn1 at hispeed dot ch","cat" "","Mowitz","Librairie pour siag","http://siag.nu/","","cat"; ... ... ... > 1100 lines Maybe because the first ""(packages.id) is empty instead of being "1","2","3","4"... but don't see how to do this automatically. I will be very pleased if someone have a clue. Thanks. ++ fredg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19394] Re: unable to parse csv file
> You should be able ti just delete the "id" column and if there are no > dates it should work. Trying with that CSV file (with and without the 1st line) : packages.nom,packages.description,packages.url,packages.packager,packages.categorie "AfterStep","Gestionnaire de fenêtres","http:// www.afterstep.org/","geanbrun","cat" "ICU","International Components for Unicode for C","http://www.icu- project.org/","","cat" "LibVNCServer","seveur VNC","http:// libvncserver.sourceforge.net/","floreal.c at orange dot fr","cat" .. .. No success :( ++ fredg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19404] Re: unable to parse csv file
> What error do you get? I don' t have any ticket just the red warning. Is there a log file where I can find something useful for you ? > Here are some other possible causes of errors: > - There are column names that do have a corresponding field in the > table > - field types do not match > - you have dates NOT in ISO format > - you have special characters in the strings (I see you have a "ê"). > Strings must be UTF8 to be imported. I have changed string to text, remove special characters from desc. (stup** frenchies :P), remove the not null condition, no dates. Here is the new db .py #!/usr/bin/python # -*- coding: utf-8 -*- db = SQLDB('sqlite://bddpackages.db') ## Table des Packages db.define_table("packages", SQLField("nom","text",length=32,notnull=True,default=""), SQLField("description","text",length=128,default=""), SQLField("url","text",length=64,default=""), SQLField("packager","text",length=64,default=""), SQLField("categorie","text",length=32,default="")) The new CSV file looks like that : packages.nom,packages.description,packages.url,packages.packager,packages.categorie "AfterStep","desc","http://www.afterstep.org/","geanbrun","cat"; "ICU","desc","http://www.icu-project.org/","","cat"; "LibVNCServer","desc","http:// libvncserver.sourceforge.net/","floreal.c at orange dot fr","cat" "MesaLib","desc","http://mesa3d.sourceforge.net","Thierry Nuttens, thierryn1 at hispeed dot ch","cat" .. .. I 've got the same warning "unable to parse CSV file", but this time only 51 packages were added to the db. I will check line by line if there is a special character somewhere ... Best regards. ++ fredg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19443] Re: unable to parse csv file
On 7 avr, 21:34, mdipierro wrote: > Because if appadmin were to give a ticket people would interpret this > as a web2py (appamdin) bug. Yes, I understand. > db.youtable.import_from_csv_file(open(,'rb')) fredg [ ~/Desktop/web2py ]$ python web2py.py -S nutyx WARNING:root:unable to import dbhash default applications appear to be installed already web2py Enterprise Web Framework Created by Massimo Di Pierro, Copyright 2007-2009 Version 1.59 (2009-03-16 13:10:16) Database drivers available: SQLite3 WARNING:root:import IPython error, use default python shell Python 2.5.4 (r254:67916, Dec 30 2008, 15:35:29) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> db.packages.import_from_csv_file(open('/tmp/db_packages.csv','rb')) Traceback (most recent call last): File "", line 1, in NameError: name 'db' is not defined I have try to add packages by hand through your web2py admin interface in my database created by : #!/usr/bin/python # -*- coding: utf-8 -*- db = SQLDB('sqlite://packages.db') ## Table des Packages db.define_table("packages", SQLField("nom","text",length=32,default=""), SQLField("description","text",length=128,default=""), SQLField("url","text",length=64,default=""), SQLField("packager","text",length=64,default=""), SQLField("categorie","text",length=32,default="")) And it works like a charm, here is the export CSV file (with special characters ;) ) packages.id,packages.nom,packages.description,packages.url,packages.packager,packages.categorie 1,b43-cutter,plop plip (po),http://www.plop.org/~down4/plop,thierryn1 at plop dot com,cat 2,tpokoij-iuhuhh32,kjihiy y_y_yy-tèuggôih,http://www.plop.pop,,cat 3,blah-blah-2,"ihyszui, yh_y_yi-zu34ih jôîuh hyuhy",http:// www.plop.plop/~ljij/123,fredg at web2py dot org,cat Hope it helps. ++ fredg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19446] Re: unable to parse csv file
Is that CSV import impossible because web2py can't set a primary key that is not id ? Not even possible with your sqldesigner : http://mdp.cti.depaul.edu/sqldesigner/default/sqldesigner I don't have any trouble importing my CSV into an sqlite database made with the firefox extension (SQLite Manager) and with my first field "nom" set as text and primary key. If I try with a db where the primary key is id, it's impossible to do the import. Trying with an db made with web2py an open with SQLite Manager too, import impossible. ++ fredg On 8 avr, 11:35, fredg wrote: > On 7 avr, 21:34, mdipierro wrote:> Because if > appadmin were to give a ticket people would interpret this > > as a web2py (appamdin) bug. > > Yes, I understand. > > > db.youtable.import_from_csv_file(open(,'rb')) > > > fredg [ ~/Desktop/web2py ]$ python web2py.py -S nutyx > WARNING:root:unable to import dbhash > default applications appear to be installed already > web2py Enterprise Web Framework > Created by Massimo Di Pierro, Copyright 2007-2009 > Version 1.59 (2009-03-16 13:10:16) > Database drivers available: SQLite3 > WARNING:root:import IPython error, use default python shell > Python 2.5.4 (r254:67916, Dec 30 2008, 15:35:29) > [GCC 4.3.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > (InteractiveConsole)>>> > db.packages.import_from_csv_file(open('/tmp/db_packages.csv','rb')) > > Traceback (most recent call last): > File "", line 1, in > NameError: name 'db' is not defined > > > I have try to add packages by hand through your web2py admin interface > in my database created by : > > #!/usr/bin/python > # -*- coding: utf-8 -*- > db = SQLDB('sqlite://packages.db') > ## Table des Packages > db.define_table("packages", > SQLField("nom","text",length=32,default=""), > SQLField("description","text",length=128,default=""), > SQLField("url","text",length=64,default=""), > SQLField("packager","text",length=64,default=""), > SQLField("categorie","text",length=32,default="")) > > > And it works like a charm, here is the export CSV file (with special > characters ;) ) > > packages.id,packages.nom,packages.description,packages.url,packages.packager,packages.categorie > > 1,b43-cutter,plop plip (po),http://www.plop.org/~down4/plop,thierryn1 > at plop dot com,cat > > 2,tpokoij-iuhuhh32,kjihiy y_y_yy-tèuggôih,http://www.plop.pop,,cat > > 3,blah-blah-2,"ihyszui, yh_y_yi-zu34ih jôîuh > hyuhy",http://www.plop.plop/~ljij/123,fredgat web2py dot org,cat > > > Hope it helps. > > ++ fredg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19496] french translation integration trouble
Hi, Running Web2py-1.60 clean install and python-2.5.4. Got a ticket if I want to edit fr-fr.py language : Error traceback Traceback (most recent call last): File "/home/fredg/Desktop/web2py/gluon/restricted.py", line 98, in restricted exec ccode in environment File "/home/fredg/Desktop/web2py/applications/admin/controllers/ default.py", line 1010, in File "/home/fredg/Desktop/web2py/gluon/globals.py", line 75, in self._caller = lambda f: f() File "/home/fredg/Desktop/web2py/applications/admin/controllers/ default.py", line 630, in edit_language strings = eval(open(apath(filename), 'r').read().replace('\r \n','\n')) File "", line 8 'Sure you want to delete this object?':'Souhaitez vous vraiment effacer ^ SyntaxError: EOL while scanning single-quoted string Here is the ticket with no copy/paste error : http://pastealacon.com/2503 ++ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---
[web2py:19502] Re: french translation integration trouble
Just in case it was a copy/paste error from the fr-fr.py file sent to you via launchpad, here it is again: http://pastealacon.com/2504 Best regards. ++ fredg On 9 avr, 14:21, fredg wrote: > Hi, > > Running Web2py-1.60 clean install and python-2.5.4. > Got a ticket if I want to edit fr-fr.py language : > > Error traceback > > Traceback (most recent call last): > File "/home/fredg/Desktop/web2py/gluon/restricted.py", line 98, in > restricted > exec ccode in environment > File "/home/fredg/Desktop/web2py/applications/admin/controllers/ > default.py", line 1010, in > File "/home/fredg/Desktop/web2py/gluon/globals.py", line 75, in > > self._caller = lambda f: f() > File "/home/fredg/Desktop/web2py/applications/admin/controllers/ > default.py", line 630, in edit_language > strings = eval(open(apath(filename), 'r').read().replace('\r > \n','\n')) > File "", line 8 > 'Sure you want to delete this object?':'Souhaitez vous vraiment > effacer > > ^ > SyntaxError: EOL while scanning single-quoted string > > Here is the ticket with no copy/paste error :http://pastealacon.com/2503 > > ++ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~--~~~~--~~--~--~---