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

[BUG] #340

Closed
1 of 2 tasks
trujaytim opened this issue May 12, 2020 · 1 comment
Closed
1 of 2 tasks

[BUG] #340

trujaytim opened this issue May 12, 2020 · 1 comment
Assignees
Labels

Comments

@trujaytim
Copy link

Describe the bug
When parsing a csv that uses " (double quote) as the quote char and ' (single quote) as the escape char, if a quoted field ends with two single quotes an error is reported. It is expected that two instances of the escape char in a field would escape-the-escape char and so the field would pass parsing successfully.

Parsing or Formatting?

  • Formatting
  • Parsing

To Reproduce
Steps to reproduce the behavior:
Code sample:

  import stream from "stream";
  import csv from "fast-csv";
  const csvString = `Col 1
"A '"Good'" row''"
`;
  const readable = stream.Readable.from(csvString);

    readable
      .pipe(csv.parse({ headers: true, escape: "'" }))
      .on('error', error => console.error(error))
      .on('data', row => console.log(row))
      .on('end', (rowCount) => console.log(`Parsed ${rowCount} rows`)); 

Expected behavior
Expect a raw field like this (it's a bit hard to read, but this string terminates with two single quotes then a double quote):

"A '"Good'" row''"

To parse to value:

A "Good" row'

However instead we get the error:

"missing closing: '"' in line: at '"A '"Good'" \n'ow''"\n'''"

If applicable, add screenshots to help explain your problem.
(not applicable)

Desktop (please complete the following information):

  • OS: Ubuntu 18
  • Node Version 12.6

Additional context
Add any other context about the problem here.

@trujaytim trujaytim added the bug label May 12, 2020
doug-martin added a commit that referenced this issue May 15, 2020
fix(parse): Handle escaped escape properly #340
@doug-martin
Copy link
Contributor

@trujaytim thank you for the detailed bug report!

A fix has be published under v4.1.6

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

No branches or pull requests

3 participants