Ok Massimo, sent you the new diff.

Now you should be able to

db.export_to_csv_file(ofile, delimiter='|', quotechar='*',
quoting=csv.QUOTE_NONNUMERIC)

db.import_from_csv_file(ofile, delimiter='|', quotechar='*',
quoting=csv.QUOTE_NONNUMERIC)

Rows.export_to_csv_file(ofile, delimiter='|', quotechar='*',
quoting=csv.QUOTE_NONNUMERIC)

-Thadeus




On Tue, Nov 3, 2009 at 2:44 PM, Thadeus Burgess <thade...@thadeusb.com>wrote:

> I also need to add the options to import_from_csv_file
>
>
> -Thadeus
>
>
>
>
>
> On Tue, Nov 3, 2009 at 2:42 PM, Thadeus Burgess <thade...@thadeusb.com>wrote:
>
>> Sure, I figured the reason against adding it to SQLDB was because it adds
>> web2py specific meta information. I will send you the new patch in a minute.
>>
>> -Thadeus
>>
>>
>>
>>
>>
>> On Tue, Nov 3, 2009 at 2:39 PM, mdipierro <mdipie...@cs.depaul.edu>wrote:
>>
>>>
>>> thanks, can you email it to me plase. Can you also add the options to
>>> SQLDB.export_to_csv
>>>
>>> On Nov 3, 2:36 pm, Thadeus Burgess <thade...@thadeusb.com> wrote:
>>> > Here is a patch to allow Rows.export_to_csv file to specify the
>>> quotechar,
>>> > delimiter, and quoting type.
>>> >
>>> > Mainly, I needed support for QOUTE_NONNUMERIC so that my data could
>>> import
>>> > to Microsoft Access.
>>> >
>>> > Massimo I will email you the diff file.
>>> >
>>> > Basically, now you can do
>>> >
>>> > Rows.export_to_csv_file(ofile, delimiter='|', qoutechar='"',
>>> > qouting=csv.QOUTE_NONNUMERIC)
>>> >
>>> > Index: gluon/sql.py
>>> > ===================================================================
>>> > --- gluon/sql.py    (revision 1381)
>>> > +++ gluon/sql.py    (working copy)
>>> > @@ -3235,14 +3235,19 @@
>>> >          for i in xrange(len(self)):
>>> >              yield self[i]
>>> >
>>> > -    def export_to_csv_file(self, ofile, null='<NULL>'):
>>> > +    def export_to_csv_file(self, ofile, null='<NULL>', *args,
>>> **kwargs):
>>> >          """
>>> >          export data to csv, the first line contains the column names
>>> >
>>> >          :param ofile: where the csv must be exported to
>>> >          :param null: how null values must be represented (default
>>> '<NULL>')
>>> >          """
>>> > -        writer = csv.writer(ofile)
>>> > +        delimiter = kwargs.get('delimiter', ',')
>>> > +        quotechar = kwargs.get('quotechar', '"')
>>> > +        quoting = kwargs.get('quoting', csv.QUOTE_MINIMAL)
>>> > +
>>> > +        writer = csv.writer(ofile, delimiter=delimiter,
>>> > quotechar=quotechar, quoting=quoting)
>>> > +
>>> >          # a proper csv starting with the column names
>>> >          writer.writerow(self.colnames)
>>> >
>>> > -Thadeus
>>> >>>
>>>
>>
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to