Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Support Comment Features #56

Closed
nezda opened this issue Nov 14, 2014 · 10 comments
Closed

Support Comment Features #56

nezda opened this issue Nov 14, 2014 · 10 comments
Milestone

Comments

@nezda
Copy link

nezda commented Nov 14, 2014

It would be useful if Feature.ALLOW_YAML_COMMENTS were supported (probably Feature.ALLOW_COMMENTS for consistency sake).

@cowtowncoder
Copy link
Member

I have been thinking about that. So, I am guessing that lines that start with '#' would be considered comments, but not ones that had '#' somewhere later on?
Also, probably no need to allow leading white space.

@nezda nezda closed this as completed Nov 14, 2014
@nezda nezda reopened this Nov 14, 2014
@nezda
Copy link
Author

nezda commented Nov 14, 2014

I would expect from wherever they are to the end of the line which does imply a little row edge whitespace trimming.

@cowtowncoder
Copy link
Member

Hmmh. This would be somewhat problematic from implementation perspective, for false matches -- is there actually usage examples of comments after data, as opposed to comment-only rows?

@nezda
Copy link
Author

nezda commented Nov 14, 2014

Its something I've done (and seen) to (temporarily) omit columns and comment on a particular row's content, but I don't have a publicly available example/precedent.

@cowtowncoder
Copy link
Member

Ok; I have hoped to find sort of emerging standard, that is why I am asking. It would be nice to follow existing practices if there were some.

Now: I think I am open to allowing comments anywhere; and perhaps it would be possible to allow more reliable handling by ensuring that comments can occur anywhere, but NOT inside quoted values; and to allow escaping (optional, default with backslash) hash sign.

Plus it is even possible to have additional setting ("comments only for beginning of line") if there are further concerns.

So I think this makes sense.

One final additional thought: in addition to existing feature (good point on that btw, I hadn't realized its relevance here!), could also add a flag in CsvSchema as an alternative. Not sure if it'd confuse things more or not, but it's worth mentioning.
Actually: doing this could allow custom comment char -- default of '#' (if enabled), but could even use soemthing else; some formats use semicolon (";") for example/

@cowtowncoder
Copy link
Member

To start off things, CsvSchema now has boolean "allow comments" flag. I did not add ability to use different comment character, assuming that use of # makes most sense to start.

@cowtowncoder
Copy link
Member

After reading documentation I could find, I further limited this so that only '#' as the first character of a line counts as a comment; this may be relaxed in future if it turns out necessary.
Also verified that leading '#' will lead to values being quoted on writing.

cowtowncoder added a commit that referenced this issue Jan 1, 2015
@cowtowncoder cowtowncoder added this to the 2.5.0 milestone Jan 1, 2015
@cowtowncoder
Copy link
Member

Implemented, will be in 2.5.0.

@nezda
Copy link
Author

nezda commented Jan 2, 2015

I really appreciate your work on this, though I can't ditch my hand rolled solution without the comments-anywhere feature as I have a raft of existing data. Should I open a separate feature request issue?

@cowtowncoder
Copy link
Member

Yes, please open a separate issue.

Adding handling in beginning of a column
(i.e. at beginning of line, or following column separator) is relatively easy; I actually started this way, but since almost all examples I saw assumed comment-starting-from-first-char, I chose a bit more conservative initial implementation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants