8000 Comma in cell value causes issues · Issue #12 · dominictarr/excel-stream · GitHub
[go: up one dir, main page]

Skip to content

Comma in cell value causes issues #12

Open

Description

@nirarazi

When my cell value included a comma (','), the row value I got inside 'data' event handler callback was truncated at the point of the comma, and was suffixed with a double quote sign ('"').

So, for example, a value of abcd, efg would result in abcd".

Activity

  1. sureshvarman commented on Sep 19, 2016

    @sureshvarman

    +1

  2. sureshvarman commented on Sep 19, 2016

    @sureshvarman
    if (options) {
        options.sheet && spawnArgs.push('--sheet') && spawnArgs.push(options.sheet) && delete options.sheet
        options.sheetIndex && spawnArgs.push('--sheet-index') && spawnArgs.push(options.sheetIndex) && delete options.sheetIndex
        options.delimiter && spawnArgs.push('-F') && spawnArgs.push(options.delimiter)
      }
    

    adding delimiter to the options solves the issue

  3. jschultz21 commented on Feb 8, 2017

    @jschultz21

    hi! I'm having a hard time with this, as well. For an xlsx file, what should the delimiter be, if not a comma?

  4. reviewher commented on Feb 8, 2017

    @reviewher

    @nirarazi @sureshvarman @jschultz21 the csv-stream module defaults to no field enclosure character. Characters like " are treated as literal, so the parser sees a CSV line like

    "abc,def","ghi,jkl"
    

    as 4 separate fields.

    According to the docs, the fix is to pass the option enclosedChar:'"' to csv-stream.

    Since excel-stream largely passes options directly to csv-stream, the simplest fix is to pass an options argument to excel-stream with the enclosedChar:'"' field. For example, if the excel file is:

    "abc,def","ghi,jkl"
    1,2
    3,4
    

    then call:

    fs.createReadStream('test.xlsx').pipe(require('excel-stream')({enclosedChar:'"'})).on('data', console.log);

    replace console.log with your normal callback function and replace the fs.createReadStream part with however you are getting the data.

  5. jschultz21 commented on Feb 8, 2017

    @jschultz21

    thank you @reviewher, this worked perfectly!

  6. 11et401012 commented on Nov 28, 2017

    @11et401012

    thank you @reviewher, this worked .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0