mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Don't parse CSV comments (#1859)
* `mlr sort -b` feature * mlr regtest -p test/cases/cli-help && make dev * Don't parse CSV comments * Add tests for PR 1346 * Add tests for PR 1787 * Add test CSV files
This commit is contained in:
parent
369156b70d
commit
06e16ea3ee
18 changed files with 62 additions and 37 deletions
|
|
@ -311,15 +311,28 @@ func (r *Reader) readRecord(dst []string) ([]string, error) {
|
|||
var errRead error
|
||||
for errRead == nil {
|
||||
line, errRead = r.readLine()
|
||||
if r.Comment != 0 && nextRune(line) == r.Comment {
|
||||
line = nil
|
||||
continue // Skip comment lines
|
||||
}
|
||||
|
||||
// MILLER-SPECIFIC UPDATE: DO NOT DO THIS
|
||||
// if r.Comment != 0 && nextRune(line) == r.Comment {
|
||||
// line = nil
|
||||
// continue // Skip comment lines
|
||||
// }
|
||||
|
||||
// MILLER-SPECIFIC UPDATE: DO NOT DO THIS
|
||||
// if errRead == nil && len(line) == lengthNL(line) {
|
||||
// line = nil
|
||||
// continue // Skip empty lines
|
||||
// line = nil
|
||||
// continue // Skip empty lines
|
||||
// }
|
||||
|
||||
// MILLER-SPECIFIC UPDATE: If the line starts with the comment character,
|
||||
// don't attempt to CSV-parse it -- just hand it back as a single field.
|
||||
// This allows two things:
|
||||
// * User comments get passed through as intended, without being reformatted;
|
||||
// * Users can do things like `# a"b` in their comments without getting an
|
||||
// imbalanced-double-quote error.
|
||||
if r.Comment != 0 && nextRune(line) == r.Comment {
|
||||
return []string{string(line)}, nil
|
||||
}
|
||||
break
|
||||
}
|
||||
if errRead == io.EOF {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue