read_csv.js 877 Bytes
const csv = require('csv-parser')
const fs = require('fs')
const results = [];
var choice = "놀거리" 

//대분류 선택 과정 필요

if(choice == "카페"){
  fs.createReadStream('cafe_list.csv')
    .pipe(csv())
    .on('data', (data) => results.push(data))
    .on('end', () => {
      console.log(results);
    });
}
else if (choice == "식사"){
  fs.createReadStream('meal_list.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log(results);
  });
}
else if (choice == "놀거리"){
  fs.createReadStream('play_list.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log(results);
  });
}
else if (choice == "술집"){
  fs.createReadStream('bar_list.csv')
  .pipe(csv())
  .on('data', (data) => results.push(data))
  .on('end', () => {
    console.log(results);
  });
}