title: Read only first row from a CSV and save it as a string
body: <p>I use Node.JS and express-fileupload to upload files from client to server. You can also view the uploaded files in your browser, delete or download them. </p>
  
  <p>Some files are <strong>csv-files</strong>. It can also already detect, if the file is a csv or not.  </p>
  
  <p>I would like to save the <strong>first row</strong> from each csv-file after it is uploaded, and save it as an <strong>array or string or JSON</strong> etc.</p>
  
  <p>So that I can show the first row in the browser.
  A simple, beginner-friendly solution would be great.</p>
  
  <p>Thank you!</p>
  
  <p><strong>UPDATE 1:</strong>
  This is how I tried to use "csv-parse":</p>
  
  <pre><code>function firstCsvRow(pCsv){    //the function for getting the FIRST ROW
      var csvData=[];                         // Array 
      fs.createReadStream('/usr/src/app/upload/' + pCsv) //here is the csv-file
          .pipe(parse(/*options:*/ {delimiter: ',', from: '0', to: '0'}))     
  //I tried to add options like in the documentation of "csv-parse", like so to speak "from line 0 to line 0", so that I'll 
  //get only the first row of the csv-file...
  
          .on('data', function(csvrow) {      // where does the 'csvrow' comes from? // I don't know what this is for
              console.log(csvrow); //also console-log shows nothing
  
              csvData.push(csvrow); //this should push the row into the Array.        
              console.log(csvData); //but again no log
          })
  
      var server = http.createServer((req,res)=&gt;{
          res.writeHead(200,{ 'content-type': 'application/json' });
          res.end('Hi');
      })
  
      server.listen(8080);
  }
  
     //where I actually USE the function for getting the FIRST ROW:
  app.post('/dateiNameTemp', (req, res) =&gt; {
  
      var dateiNameServer = req.body.eingabeFeld1;       //here we get the name of the csv-file
  
          //Download csv-file  
      app.get('/' + dateiNameServer, (req, res) =&gt; {
          res.download('/usr/src/app/upload/' + dateiNameServer);
  
      })
  
      firstCsvRow(dateiNameServer);    //!!! this one causes errors...
  });
  </code></pre>
  
  <p>After all, I don't understand very well what is going on. When I execute the code, it gives errors on serverside: </p>
  
  <pre><code>events.js:183
        throw er; // Unhandled 'error' event
        ^
  
  Error: listen EADDRINUSE :::8080
      at Object._errnoException (util.js:1022:11)
      at _exceptionWithHostPort (util.js:1044:20)
      at Server.setupListenHandle [as _listen2] (net.js:1367:14)
      at listenInCluster (net.js:1408:12)
      at Server.listen (net.js:1492:7)
      at firstCsvRow (/usr/src/app/chart1.js:235:9)
      at app.post (/usr/src/app/chart1.js:268:2)
      at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)
      at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)
      at Route.dispatch (/usr/src/app/node_modules/express/lib/router/route.js:112:3)
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! ssa-deviceshadow-app@1.0.0 start: `node chart1.js`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the ssa-deviceshadow-app@1.0.0 start script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /root/.npm/_logs/2018-07-10T13_01_28_574Z-debug.log
  </code></pre>