Node.js使用Sails解析csv-parse错误

时间:2016-12-29 02:16:13

标签: node.js csv sails.js

它处理.csv文件中的大多数记录。但是,最后我用csv-parse节点模块得到了这个错误,并且无法弄清楚原因。它终止了我的服务器,所以我需要解决它。请帮忙

string InpStr = "TX-23443 or FUX3329442";
MatchCollection ms = Regex.Matches(InpStr, @"[A-Za-z-]*\d{3,}");
foreach(Match m in ms)
{
    Console.WriteLine(m);
}

我的控制器API

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: Number of columns on line 37052 does not match header
    at Error (native)
    at Parser.__push (/Users/Development/apps/SailsJS/my-project/node_modules/csv-parse/lib/index.js:222:13)
    at Parser._flush (/Users/Development/apps/SailsJS/my-project/node_modules/csv-parse/lib/index.js:189:12)
    at Parser.<anonymous> (_stream_transform.js:118:12)
    at Parser.g (events.js:291:16)
    at emitNone (events.js:86:13)
    at Parser.emit (events.js:185:7)
    at prefinish (_stream_writable.js:504:12)
    at finishMaybe (_stream_writable.js:512:7)
    at endWritable (_stream_writable.js:524:3)
    at Parser.Writable.end (_stream_writable.js:489:5)
    at ReadStream.onend (_stream_readable.js:511:10)
    at ReadStream.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at ReadStream.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

1 个答案:

答案 0 :(得分:0)

我切换到使用fast-csv模块并且工作了。