mholt / PapaParse

Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
http://PapaParse.com
MIT License
12.3k stars 1.14k forks source link

Extra symbol in first row · #1043

Closed caoxing9 closed 4 months ago

caoxing9 commented 4 months ago

I parse a csv like csv content

hello,q,q
12,2,2
21,2,

parse function

async parse(options: Papa.ParseConfig) {
    const fileStream = await this.getFile();
    return await new Promise((resolve, reject) => {
      Papa.parse(fileStream, {
        header: false,
        dynamicTyping: true,
        complete: function (results) {
          resolve(results.data);
        },
        error: (error) => {
          reject(error);
        },
        ...options,
      });
    });
  }

then the result is

{
  data: [ [ '·hello', 'q', 'q' ], [ 12, 2, 2 ], [ 21, 2, null ] ],
  errors: [],
  meta: {
    delimiter: ',',
    linebreak: '\r\n',
    aborted: false,
    truncated: false,
    cursor: 25
  }
}

you see the first row hello have an extal symbol, but node can't recognize it

what's more, it only apear in string type, if the first row data is number, it is normal

extra discover, the csv file from excel by saving will meet this problem, if i create csv file by vscode, it won't.

example csv file Book4.csv

pokoli commented 4 months ago

I tested your sample file in the demo instance and no extra simbol is shown.

I guess the symbol is present on the source file and for this reason is shown when parsing.

Nothing to do from our side.