{"action":"opened","issue":{"url":"https://api.github.com/repos/wdavidw/node-csv-parse/issues/75","repository_url":"https://api.github.com/repos/wdavidw/node-csv-parse","labels_url":"https://api.github.com/repos/wdavidw/node-csv-parse/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/wdavidw/node-csv-parse/issues/75/comments","events_url":"https://api.github.com/repos/wdavidw/node-csv-parse/issues/75/events","html_url":"https://github.com/wdavidw/node-csv-parse/issues/75","id":132264039,"number":75,"title":"Support optional header lines","user":{"login":"ZoltanLajosKis","id":769858,"avatar_url":"https://avatars.githubusercontent.com/u/769858?v=3","gravatar_id":"","url":"https://api.github.com/users/ZoltanLajosKis","html_url":"https://github.com/ZoltanLajosKis","followers_url":"https://api.github.com/users/ZoltanLajosKis/followers","following_url":"https://api.github.com/users/ZoltanLajosKis/following{/other_user}","gists_url":"https://api.github.com/users/ZoltanLajosKis/gists{/gist_id}","starred_url":"https://api.github.com/users/ZoltanLajosKis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZoltanLajosKis/subscriptions","organizations_url":"https://api.github.com/users/ZoltanLajosKis/orgs","repos_url":"https://api.github.com/users/ZoltanLajosKis/repos","events_url":"https://api.github.com/users/ZoltanLajosKis/events{/privacy}","received_events_url":"https://api.github.com/users/ZoltanLajosKis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-08T21:41:44Z","updated_at":"2016-02-08T21:41:44Z","closed_at":null,"body":"It seems csv-parse assumes that if I specify a columns function, then the first line in the input is a header line. Even if the function returns null, the first line is consumed and not emitted as data.\r\n\r\nIt would be nice if the columns function could also signal with its return value that:\r\n1) no, the first line wasn't a header, just use it as data, and don't use column names (parse into array)\r\n2) no, the first line wasn't a header, just use it as data, and use the following column names\r\n\r\nI have the following workaround to simulate 2), but it looks ugly and fragile:\r\n```js\r\nlet cs = csv.parse({\r\n  columns: (firstLine) => {\r\n    if (isHeaderLine(firstLine)) {\r\n      return firstLine;    // first line indeed contains column names\r\n    }\r\n\r\n    const cols = [\"Col1\", \"Col2\", \"Col3\"]; // use these column names\r\n\r\n    let firstData = {}; // and use first line as regular data\r\n    for (let i=0; i < Math.min(cols.length, firstLine.length); i++) {\r\n      firstData[cols[i]] = firstLine[i];\r\n    }\r\n\r\n    cs.emit('data', firstData);\r\n    return cols;\r\n  }\r\n});\r\n\r\nfs.createReadStream(\"test.csv\").pipe(cs);\r\ncs.on('data', function (data) { console.log(\"DATA\", data) });\r\n```"}}