Fredrik Lundh wrote:
> John Machin wrote:
>
> > Given Peter Otten's post, looks like
> > (1) there's a bug in the "fmtparam" mechanism -- it's ignoring the
> > escapechar in my first twiddle, which should give the same result as
> > Peter's.
> > (2)
> > | >>> csv.excel.doublequote
> > True
> > Acc
John Machin wrote:
> | >>> s='"123","a,b,\"c\"",5.640'
Note how I fixed the input:
>>> '"123","a,b,\"c\"",5.640'
'"123","a,b,"c"",5.640'
>>> '"123","a,b,\\"c\\"",5.640'
'"123","a,b,\\"c\\"",5.640'
Peter
--
http://mail.python.org/mailman/listinfo/python-list
John Machin wrote:
> John Machin wrote:
> > Fredrik Lundh wrote:
> > > robert wrote:
> > >
> > > > What is a most simple expression for splitting a CSV line
> > > > with "-protected fields?
> > > >
> > > > s='"123","a,b,\"c\"",5.640'
> > >
> > > import csv
> > >
> > > the preferred way is to read
John Machin wrote:
> Given Peter Otten's post, looks like
> (1) there's a bug in the "fmtparam" mechanism -- it's ignoring the
> escapechar in my first twiddle, which should give the same result as
> Peter's.
> (2)
> | >>> csv.excel.doublequote
> True
> According to my reading of the docs:
> """
>
John Machin wrote:
> Fredrik Lundh wrote:
> > robert wrote:
> >
> > > What is a most simple expression for splitting a CSV line
> > > with "-protected fields?
> > >
> > > s='"123","a,b,\"c\"",5.640'
> >
> > import csv
> >
> > the preferred way is to read the file using that module. if you insist
Fredrik Lundh wrote:
> robert wrote:
>
> > What is a most simple expression for splitting a CSV line
> > with "-protected fields?
> >
> > s='"123","a,b,\"c\"",5.640'
>
> import csv
>
> the preferred way is to read the file using that module. if you insist
> on processing a single line, you can do
robert wrote:
> What is a most simple expression for splitting a CSV line with "-protected
> fields?
>
> s='"123","a,b,\"c\"",5.640'
>>> import csv
>>> class mydialect(csv.excel):
... escapechar = "\\"
...
>>> csv.reader(['"123","a,b,\\"c\\"",5.640'], dialect=mydialect).next()
['123', 'a,b,"
robert wrote:
> What is a most simple expression for splitting a CSV line with "-protected
> fields?
>
> s='"123","a,b,\"c\"",5.640'
Use the csv-module. It should have a dialect for this, albeit I'm not 100%
sure if the escaping of the " is done properly from csv POV. Might be that
it requires e
robert wrote:
> What is a most simple expression for splitting a CSV line
> with "-protected fields?
>
> s='"123","a,b,\"c\"",5.640'
import csv
the preferred way is to read the file using that module. if you insist
on processing a single line, you can do
cols = list(csv.reader([string]
s.split(',');
robert wrote:
> What is a most simple expression for splitting a CSV line with "-protected
> fields?
>
> s='"123","a,b,\"c\"",5.640'
--
http://mail.python.org/mailman/listinfo/python-list
What is a most simple expression for splitting a CSV line with "-protected
fields?
s='"123","a,b,\"c\"",5.640'
--
http://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo