build/modelscript.umd.js
async function loadCSV(filepath, options) {
              if (validUrl.isUri(filepath)) {
                return loadCSVURI(filepath, options);
              } else {
                return new Promise((resolve, reject) => {
                  const csvData = [];
                  const config = Object.assign({ checkType: true, }, options);
                  csvtojson(config).fromFile(filepath)
                    .on('json', jsonObj => {
                      csvData.push(jsonObj);
                    })
                    .on('error', err => {
                      return reject(err);
                    })
                    .on('done', error => {
                      if (error) {
                        return reject(error);
                      } else {
                        return resolve(csvData);
                      }
                    });
                });
              }
            }
async function loadCSV(filepath, options) {
              if (validUrl.isUri(filepath)) {
                return loadCSVURI(filepath, options);
              } else {
                return new Promise((resolve, reject) => {
                  const csvData = [];
                  const config = Object.assign({ checkType: true, }, options);
                  csvtojson(config).fromFile(filepath)
                    .on('json', jsonObj => {
                      csvData.push(jsonObj);
                    })
                    .on('error', err => {
                      return reject(err);
                    })
                    .on('done', error => {
                      if (error) {
                        return reject(error);
                      } else {
                        return resolve(csvData);
                      }
                    });
                });
              }
            }
async function loadCSV ( filepath , options ) { if ( validUrl . isUri ( filepath ) ) { return loadCSVURI ( filepath , options ) ; } else { return new Promise ( ( resolve , reject ) => { const csvData = [ ] ; const config = Object . assign ( { checkType : true , } , options ) ; csvtojson ( config ) . fromFile ( filepath ) . on ( 'json' , jsonObj => { csvData . push ( jsonObj ) ; } ) . on ( 'error' , err => { return reject ( err ) ; } ) . on ( 'done' , error => { if ( error ) { return reject ( error ) ; } else { return resolve ( csvData ) ; } } ) ; } ) ; } }
Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects
@example
// returns [{header:value,header2:value2}]
loadCSV('../mock/invalid-file.csv').then(csvData).catch(console.error)
@memberOf csv
@param {string} filepath - URL to CSV path
@param {Object} [options] - options passed to csvtojson
@returns {Object[]} returns an array of objects from a csv where each column header is the property name
Asynchronously loads a CSV from either a filepath or remote URL and returns an array of objects