김연우

modify read_csv

Showing 1 changed file with 38 additions and 37 deletions
......@@ -129,44 +129,10 @@ app.post('/hook', function (req, res) {
}
res.sendStatus(200);
chooseFile = function () {
if (destCar == "cafe") {
fs.createReadStream('cafe_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "meal") {
fs.createReadStream('meal_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "play") {
fs.createReadStream('play_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "bar") {
fs.createReadStream('bar_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
}
chooseFile();
chooseFile();
});
try {
......@@ -186,3 +152,38 @@ try {
const csv = require('csv-parser')
const results = [];
chooseFile = function () {
if (destCar == "cafe") {
fs.createReadStream('cafe_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "meal") {
fs.createReadStream('meal_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "play") {
fs.createReadStream('play_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "bar") {
fs.createReadStream('bar_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
}
\ No newline at end of file
......