Allow specifying comment character for CSV reader#5759
Merged
tustvold merged 1 commit intoapache:masterfrom May 13, 2024
Merged
Allow specifying comment character for CSV reader#5759tustvold merged 1 commit intoapache:masterfrom
tustvold merged 1 commit intoapache:masterfrom
Conversation
This patch adds reader support for a comment character for reading CSV
files. While comments like almost nothing around the CSV format are not
truly standardized, a common format supported by many CSV
readers[^1][^2] is to ignore full lines starting with a comment
character (often `#`); inline or end of line comments are not supported.
Example:
# This is a comment in a CSV file without header.
1,2
# Comment inside the data block.
11,22
The implementation of this for Arrow is pretty straight-forward as all
we need to do is expose the existing `comment` option of `csv_core` used
to read CSV files.
Closes apache#5758.
[^1]: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html
[^2]: https://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html
Member
Author
|
The CI failure for |
bbannier
added a commit
to bbannier/datafusion
that referenced
this pull request
May 12, 2024
This commit switches to used version of arrow-rs to the version of apache/arrow-rs#5759 which introduces support for comments in CSV input files.
bbannier
added a commit
to bbannier/datafusion
that referenced
this pull request
May 12, 2024
This commit switches to used version of arrow-rs to the version of apache/arrow-rs#5759 which introduces support for comments in CSV input files.
bbannier
added a commit
to bbannier/datafusion
that referenced
this pull request
May 12, 2024
This commit switches to used version of arrow-rs to the version of apache/arrow-rs#5759 which introduces support for comments in CSV input files.
tustvold
approved these changes
May 13, 2024
Contributor
tustvold
left a comment
There was a problem hiding this comment.
Looks good to me, thank you.
Integration test failure is unrelated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch adds reader support for a comment character for reading CSV files. While comments like almost nothing around the CSV format are not truly standardized, a common format supported by many CSV readers12 is to ignore full lines starting with a comment character (often
#); inline or end of line comments are not supported.Example:
The implementation of this for Arrow is pretty straight-forward as all we need to do is expose the existing
commentoption ofcsv_coreused to read CSV files.Closes #5758.
Footnotes
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html ↩
https://stat.ethz.ch/R-manual/R-devel/library/utils/html/read.table.html ↩