About  fields like:   [Timmie, LLC] - are you having a problem?  Have you
tried this?

The generated CSV already handles this, output looking like this:

Name, Company, email
Timmie,"Timmie, LLC", [email protected]


Dialect.quoting level is one of the more useful parameters for web2py
applications to be able to manipulate.

The argument of "official excel" seems weak to me  - I have experienced
(during PyCon) excel fails to import some of the generated csv (where, for
example, open office does not fail);  also, excel can handle '\n' for
newline in csv;
The argument Timmie puts forth is weak too (comma in field;  as
for delimiter use: you already have a way to generate your own csv - just
make your own function and setup as you want.... inconvenient but possible
when you need it).

However, when using simple builtin web2py facilites quickly (PyCon was a
case this hurt me) it would be convenient to be able to set / play with csv
formatting parameters as you want.

>From the csv  documentation:
"""
When creating reader <http://docs.python.org/library/csv.html#csv.reader> or
writer <http://docs.python.org/library/csv.html#csv.writer> objects, the
programmer can specify a string or a subclass of the
Dialect<http://docs.python.org/library/csv.html#csv.Dialect> class
as the dialect parameter.
"""
I think having a pair global dialects in web2py is the way to go.  One the
application can setup, modify; one would be used for internal web2py uses
(e.g. admin use).    Setting the dialect name (a string) would work; using
that name as the dialect in all the csv.read() and csv.write()
instantiations would do the trick.
The default dialect, "excel" is what web2py uses.  A "web2py_app" dialect
could be registered with csv, application could set this up, and gluon would
use a variable to hold the correct dialog name - default for internal uses,
app for all others.   Creating a writer (for example) would look like:

web2py_dialact = 'web2py_app' # if not for internal uses
writer=csv.writer(file, dialect=web2py_dialect)


This may be important, but certainly not urgent.


- Yarko

On Mon, Apr 27, 2009 at 9:52 AM, Timmie <[email protected]> wrote:

>
> "Official Excel" also varies by coutry / regional settings.
>
> But I think by adding arguments of which the default values reflect
> the current behaviour you can improve while staying compatible.
>
> example:
>
> def export_to_csv(rows, ofile, delimiter=',', text_wrap=''):
>
>
> But thanks that you will look into this.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to