The few times I looked at CSV module it never looked useful to me. I seem to use shlex for everything. For example:

def csv_split (s):
        lex = shlex.shlex(s, posix=True)
        lex.whitespace_split = True
        lex.whitespace = ','
        return list(lex)

will split on commas while honoring quoted values (and stripping out the quotes)

Dave


On 2019/11/17 08:18, Antoon Pardon wrote:
This is python 2.6->2.7 and 3.5->3.7

I need to convert a string that is a csv line to a list and vice versa.
I thought to find functions doing this in the csv module but that doesn't
seem to be the case.

I can of course write special classes that would allow for this using
a csv.reader and csv.writer but that would be some convoluted code.

Anyone some suggestions?

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to