xxxxxxxxxx
const fs = require('fs');
const csv = require('csv-parser');
const filePath = 'your_csv_file.csv';
const columnToGroupBy = 'Column1'; // Change this to the name of the column you want to group by
const columnToExtract = 'Column2'; // Change this to the name of the column you want to extract
const groupedData = {};
fs.createReadStream(filePath)
.pipe(csv())
.on('data', (row) => {
const groupKey = row[columnToGroupBy];
const value = row[columnToExtract];
if (!groupedData[groupKey]) {
groupedData[groupKey] = [];
}
groupedData[groupKey].push(value);
})
.on('end', () => {
console.log('Data grouped:', groupedData);
});