diff --git a/data/people.csv b/data/people.csv new file mode 100644 index 0000000..2845333 --- /dev/null +++ b/data/people.csv @@ -0,0 +1,3 @@ +id, name, age +1, Sambo Chea, 24 +2, Ponlork Chea, 12 \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..423cfa4 --- /dev/null +++ b/src/index.js @@ -0,0 +1,16 @@ +const file = require('fs') + +file.readFile('./data/people.csv', 'utf-8', (err, data) => { + if (err) { + console.error(err) + return + } + + console.log(data) + + const rows = data.split(/\r?\n/); + const header = rows[0].split(',').map(str => str.trim()) + console.log(header) + +}); +