Can you try instead
import StringIO
db.yourtable.import_from_csv_file(StringIO.StringIO(your_csv_string))
and see what happens? Booleans should be T/F not 1/0.
Massimo
On Nov 23, 8:23 am, "Daniel Contag" <[EMAIL PROTECTED]> wrote:
> Hi everyone, some progress has been made... :)
>
> Adding this to gql.py I am able to import tables that contain strings.
> However I receive a type error when importing a table that has a
> column of type boolean.
>
> The code: contrib/gql.py
>
> class SQLTable(SQLStorage):
> [..]
>
> def import_from_csv_string(self, csv_string):
> """
> # changed by dc.
> import records from csv STRING. Column headers must have same names as
> table fields. (field 'id' is ignored.) If column names read
> 'table.file'
> the 'table.' prefix is ignored.
> """
> # reader needs an iterable that returns a line each time
> csv_list = []
> for l in csv_string.split('\n'):
> csv_list.append(l)
>
> reader = csv.reader(csv_list)
> colnames=None
> for line in reader:
> if not colnames:
> colnames=[x[x.find('.')+1:] for x in line]
> # c=[i for i in xrange(len(line)) if colnames[i]!='id']
> c=[i for i in xrange(len(line))]
> else:
> items=[(colnames[i],line[i]) for i in c]
> self.insert(**dict(items))
>
> The error:
>
> ERROR 2008-11-23 14:11:57,150 main.py] Traceback (most recent call last):
> File "/path/gluon/restricted.py", line 62, in restricted
> exec ccode in environment
> File "/path/applications/my_app/models/db.py", line 52, in <module>
> db.is_free.import_from_csv_string(result.content)
> File "/path/gluon/contrib/gql.py", line 218, in import_from_csv_string
> self.insert(**dict(items))
> File "/path/gluon/contrib/gql.py", line 190, in insert
> tmp=self._tableobj(**fields)
> File
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py",
> line 587, in __init__
> prop.__set__(self, value)
> File
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py",
> line 387, in __set__
> value = self.validate(value)
> File
> "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/db/__init__.py",
> line 2132, in validate
> raise BadValueError('Property %s must be a bool' % self.name)
> BadValueError: Property free must be a bool
>
> Daniel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---