I've a CSV file, with number of columns (containing headers as column ID), under each column there are set of rows (contains data for each column) but not each column's rows are equal (eg: col1, could have 4 rows .. but col2 could have 8 rows.)
what i want to do i'm trying to read the data of each column and save it in a list to use it later in some processing.
I'm trying to use CSV-parser but i couldn't figure out how to access the data of a specific column only.
here is a sample of the csv
1 ,2
How do I change my password? ,Why we use bottels?
How can I change my password? ,Why you're lazy?
How do I reset my password? ,Why do I get the message that the name of my APK is in use?
How to do a password change?
How do I do a password change?
How can a password be changed?
I've been trying to this so far
fs.createReadStream('test.csv')
.pipe(csv())
.on('data', (row) => {
//console.log('New row ',row);
if (columns === null) {
columns = [];
Object.keys(row).forEach(function (c) {
console.log(c) // this print headers only
//columns.push(c);
})
}
Object.entries(row).forEach((r)=>{
console.log(r) // this prints the entire objects data
})
What i want at the end is to have an array of arrays containing each columns data in a separate arr, (eg; Arr = [ [col1 data(6 rows)] , [col2 data(3 rows)] ]
My real csv file have a like 10000 column and in future it might be bigger.