Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import express from 'express'
  2. const app = express()
  3.  
  4. app.get('/import', async (req, res) => {
  5. var fs = require('fs')
  6.  
  7. fs.createReadStream('./src/data.csv')
  8. .pipe(parse({
  9. delimiter: ',',
  10. skip_lines_with_error: true
  11. }))
  12. .on('error', function (err) { console.log(err) })
  13. .on('data', async function (row) {
  14. // do a lot of stuff here
  15. })
  16.  
  17. res.status(200)
  18. })
  19.  
  20. export const import = (req, res) => {
  21. var fs = require('fs')
  22.  
  23. fs.createReadStream('./src/data.csv')
  24. .pipe(parse({
  25. delimiter: ',',
  26. skip_lines_with_error: true
  27. }))
  28. .on('error', function (err) { console.log(err) })
  29. .on('data', async function (row) {
  30. // do a lot of stuff here
  31. })
  32.  
  33. res.status(200)
  34. }
  35.  
  36. import express from 'express'
  37. const app = express()
  38.  
  39. app.get('/import') // <-- ??
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement