title: How do I cleanse the data (removing parenthesis and quotes) in NodeJS?
body: <p>I have a csv sheet where some of the cells could have either single record or multiple records like an array. A sample cell would look like either ["London"] or ["Cairo", "Montreal", "Paris"] - with the parenthesis included. I'm using sever.js to show these records in a visualization on a webpage.</p>
  
  <p>Everything's fine except the parenthesis and quotes are being shown in the visualization. How do I write a rule/logic in nodeJS such that both parenthesis and quotes are not shown in the final visualization?</p>
  
  <p>There's no point in cleansing the data in the csv file itself because I'm gonna have to use this code for hundreds of csv files, so it's better to write a rule in nodeJS.</p>
  
  <p>The following's the server.js code I've used so far:</p>
  
  <pre><code>/**
  * API for getting country Names
  */
  app.get('/get-country-names.json', (req, res) =&gt; {
  william.william().then(response =&gt; {
      res.json(response);
  }).catch(message =&gt; res.send("Failed to read file" + message));
  });
  
  /**
  * API to read file and return response in json
  * Takes country id as parameter
  */
  app.post('/get-city-sources.json', (req, res) =&gt; {
  let countryName = req.body.countryName;
  let city = req.body.city;
  
  william.william().then(sources =&gt; {
      let filteredSources = [{ name: city, parent: null, color: 'red' }];
      Array.from(new Set(sources.filter(source =&gt; source.countryName === countryName &amp;&amp; source.city === city).map(src =&gt; src.source)))
      .forEach(source =&gt; {
          let sourceArr = source.split(',');
          console.log(sourceArr);
          sourceArr.forEach(src =&gt; filteredSources.push({ name: src, parent: city, color: 'blue' }));
      });
      res.json(filteredSources);
  }).catch(message =&gt; res.send("Failed to read file" + message));
  });
  
  app.listen(port, () =&gt; console.log(`Example app listening at http://localhost:${port}`))
  </code></pre>