Skip to content

Instantly share code, notes, and snippets.

@cs09g
Last active June 16, 2020 13:36
Show Gist options
  • Save cs09g/b6f9e1af43cf8c4b47cb8b4d10c604b5 to your computer and use it in GitHub Desktop.
Save cs09g/b6f9e1af43cf8c4b47cb8b4d10c604b5 to your computer and use it in GitHub Desktop.
[nodejs] parsing remote csv (feat. csv-parser)
const http = require("http");
const csv = require("csv-parser");
const csvPath = "http://remoteurl/some.csv";
const results = [];
http.get(csvPath,
(response) => {
response
.pipe(csv())
.on("data", (chunk) => results.push(chunk))
.on("end", () => {
// "results" is the parsed csv
// do what you want
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment