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

ENH: Support for multiple comment characters with readers #8727

Closed
ebran opened this issue Nov 4, 2014 · 5 comments
Closed

ENH: Support for multiple comment characters with readers #8727

ebran opened this issue Nov 4, 2014 · 5 comments
Labels
Enhancement IO CSV read_csv, to_csv

Comments

@ebran
Copy link

ebran commented Nov 4, 2014

I would be very pleased if Pandas supported multiple comment characters when reading data from files. According to:

import pandas as pd
df = pd.read_table("data.dat", comment=("#","@"), delim_whitespace=True)

I don't know if this is requires a minor or major implementation effort?

Best,
Erik

@jreback jreback added IO CSV read_csv, to_csv Enhancement labels Nov 4, 2014
@jreback jreback added this to the Someday milestone Nov 4, 2014
@jreback
Copy link
Contributor

jreback commented Nov 4, 2014

this would be a bit of an effort. the reader is basically byte by byte (with some backref capability). So it would have to check agains a buffer of the comment chars (it just checks against the single char now, but only if its not NULL), in a performant manner. Could be done.

@dansondergaard
Copy link

Related:

Would be great if a comment character could actually also be two characters, e.g. "##". For example, in VCF files, some meta data is specified at the beginning of the file with "##" before the actual table starts:

http://www.internationalgenome.org/wiki/Analysis/vcf4.0/

Often one just wants to ignore these, but:

df = pd.read_csv("data.vcf", comment="##")

doesn't work. Note that for VCF it won't work to just use comment="#" since the header line actually starts with a single "#".

@wesm
Copy link
Member

wesm commented Jul 6, 2018

This would be difficult. I'm closing this for now

@wesm wesm closed this as completed Jul 6, 2018
@loodvn
Copy link

loodvn commented Sep 16, 2022

I ran into this feature request when reading a VCF file as the others did.

## Metadata
## ...
# Header
col1, col2, etc

Is the cparser the difficult part of this change?

@loodvn loodvn mentioned this issue Sep 18, 2022
5 tasks
@loodvn
Copy link

loodvn commented Sep 18, 2022

Starting a draft PR at #48615, I imagine getting the look-ahead into the state machine of C might be a bit tricky but I'll try give it a go if necessary. Also will check benchmarking for any regressions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants