Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi-character delimiters in csv #59363

Closed
RamchandraApte mannequin opened this issue Jun 24, 2012 · 6 comments
Closed

Add support for multi-character delimiters in csv #59363

RamchandraApte mannequin opened this issue Jun 24, 2012 · 6 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@RamchandraApte
Copy link
Mannequin

RamchandraApte mannequin commented Jun 24, 2012

BPO 15158
Nosy @smontanaro, @terryjreedy

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-03-08.21:44:32.041>
created_at = <Date 2012-06-24.03:47:25.275>
labels = ['type-feature', 'library']
title = 'Add support for multi-character delimiters in csv'
updated_at = <Date 2013-03-09.03:31:36.248>
user = 'https://bugs.python.org/RamchandraApte'

bugs.python.org fields:

activity = <Date 2013-03-09.03:31:36.248>
actor = 'Ramchandra Apte'
assignee = 'none'
closed = True
closed_date = <Date 2013-03-08.21:44:32.041>
closer = 'terry.reedy'
components = ['Library (Lib)']
creation = <Date 2012-06-24.03:47:25.275>
creator = 'Ramchandra Apte'
dependencies = []
files = []
hgrepos = []
issue_num = 15158
keywords = []
message_count = 6.0
messages = ['163708', '163709', '164440', '171947', '183766', '183788']
nosy_count = 4.0
nosy_names = ['skip.montanaro', 'terry.reedy', 'tshepang', 'Ramchandra Apte']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue15158'
versions = ['Python 3.4']

@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Jun 24, 2012

It would be nice if csv supported multi-character delimiters.
I need it for my project.
Another person had this problem: http://stackoverflow.com/questions/6352409/how-to-use-python-csv-module-for-splitting-double-pipe-delimited-data .

@RamchandraApte RamchandraApte mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 24, 2012
@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Jun 24, 2012

BTW, conincidentally just like the stackoverflow, even I want to split double pipes

@terryjreedy
Copy link
Member

Did you read "Unfortunately, delimiter is represented by a character in C." in one of the answers? If so, this should be rejected. For the posted problem, I added the following.

>>> list(s[1:-1] for s in '"1234"||"abcd"||"a1s1"'.split('||'))
['1234', 'abcd', 'a1s1']

re.split is intended for general splitting tasks. The SO had other posted solutions that also do the job. So I do not see the need.

Using commas both within quoted fields and between fields is semi-sensible, or at least widely done. Anyway, csv was designed for that and then generalized. I do not see the need to cater to something as foolish and rare as using a multichar delimiter that is also within fields.

I suggest you post enhancement ideas on python-ideas first, as it is a better place for discussion and reaches more people.

@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Oct 4, 2012

I do not see the need to cater to something as foolish and rare as using a multichar delimiter that is also within fields.
I need to generate tables for Google Code wikis.

@terryjreedy
Copy link
Member

You did not explain why it is *impossible* for you to use any of the other solutions. In any case, I looked at the C code. It defines delimiter (as well as quotechar and escapechar) as a single unicode char. This is different from Python which does not have a char type but uses strings (arrays) of length one as a substitute. Redefining delimiter as an array of unicode chars, as you propose, would complicate the code. It will take a much stronger case than one person's 'It would be nice' to motivate someone with the needed C skills to do the revision. It would as least slightly slow down all single char uses. It would be easier and more useful, in some ways, to write a Python csv version.

You might look elsewhere for an enhanced csv reader that handles multi-char delimiters. Searching just pypi for 'csv' returns perhaps 50 hits. If you really want to pursue this for the stdlib, follow my suggestion of posting to python-ideas and reference this issue.

@RamchandraApte
Copy link
Mannequin Author

RamchandraApte mannequin commented Mar 9, 2013

I have posted on python-ideas.

On 9 March 2013 03:14, Terry J. Reedy <report@bugs.python.org> wrote:

Terry J. Reedy added the comment:

You did not explain why it is *impossible* for you to use any of the other
solutions. In any case, I looked at the C code. It defines delimiter (as
well as quotechar and escapechar) as a single unicode char. This is
different from Python which does not have a char type but uses strings
(arrays) of length one as a substitute. Redefining delimiter as an array of
unicode chars, as you propose, would complicate the code. It will take a
much stronger case than one person's 'It would be nice' to motivate someone
with the needed C skills to do the revision. It would as least slightly
slow down all single char uses. It would be easier and more useful, in some
ways, to write a Python csv version.

You might look elsewhere for an enhanced csv reader that handles
multi-char delimiters. Searching just pypi for 'csv' returns perhaps 50
hits. If you really want to pursue this for the stdlib, follow my
suggestion of posting to python-ideas and reference this issue.

----------
nosy: +skip.montanaro
resolution: -> rejected
stage: test needed -> committed/rejected
status: open -> closed


Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue15158\>


@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant