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

Enable to switch off the removal of comments in csv2rec. #1699

Merged
merged 2 commits into from Jan 29, 2013

Conversation

gatagat
Copy link
Contributor

@gatagat gatagat commented Jan 24, 2013

This patch adds a possibility to pass comments=None to csv2rec in order to switch off comments removal.

A real world example are CSV files where the header on the first line is introduced by a hash #. As a hash is the default value for the comments option, the header is ignored. To read such files including the header one has to call csv2rec with something like comments='AStringThatNeverHappensToBeAtTheBeginingOfTheLine' which is not clear from the documentation and which seems more like a hack than a solution.

Currently, the docstring gives no hint about this behaviour and is misleading in the sense that it speaks about a character not a string:

- *comments*: the character used to indicate the start of a comment  in the file

@@ -2109,7 +2109,7 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
files is automatic, if the filename ends in '.gz'

- *comments*: the character used to indicate the start of a comment
in the file
in the file, or None to switch off the removal of comments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do *None* (asterisks around the word None), please? We are in the process of updating our docs to a consistent standard notation.

@gatagat
Copy link
Contributor Author

gatagat commented Jan 24, 2013

There is also the load function which has a comments option with the same behavior but I guess it does not make sense to change it as load() is deprecated (?).

@WeatherGod
Copy link
Member

travis failures are likely duds. The code change is simple enough, and I guess it is reasonable. There is always the question of whether one should be able to ignore the comment symbol in the first line only, but that is starting to get complicated, and we are just a graphing library. I see no reason not to merge this as-is. I'll leave this up for the day in case anybody has any objections.

WeatherGod added a commit that referenced this pull request Jan 29, 2013
Enable to switch off the removal of comments in csv2rec.
@WeatherGod WeatherGod merged commit b69cc7c into matplotlib:master Jan 29, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants