to-array-from-csv.js 272 B

123456789101112131415
  1. // converts csv item to array
  2. const toArrayFromCsv = (text) => {
  3. let array = [];
  4. if (text == null) {
  5. return array;
  6. }
  7. array = text.split(',').map(el => el.trim());
  8. array = array.filter(el => el !== '');
  9. return array;
  10. };
  11. module.exports = toArrayFromCsv;