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