How to use the d3-dsv.dsvFormat function in d3-dsv

To help you get started, we’ve selected a few d3-dsv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tinuzz / wp-plugin-trackserver / trackserver-omnivore.js View on Github external
featurecollection.crs = {type: 'name', properties: {name: crs}};
    }

    if (options.delimiter === 'auto' && typeof x == 'string') {
        options.delimiter = autoDelimiter(x);
        if (!options.delimiter) {
            callback({
                type: 'Error',
                message: 'Could not autodetect delimiter'
            });
            return;
        }
    }

    var parsed = (typeof x == 'string') ?
        dsv.dsvFormat(options.delimiter).parse(x) : x;

    if (!parsed.length) {
        callback(null, featurecollection);
        return;
    }

    var errors = [];
    var i;


    if (!latfield) latfield = guessLatHeader(parsed[0]);
    if (!lonfield) lonfield = guessLonHeader(parsed[0]);
    var noGeometry = (!latfield || !lonfield);

    if (noGeometry) {
        for (i = 0; i < parsed.length; i++) {
github vega / vega / packages / vega-loader / src / formats / dsv.js View on Github external
export default function dsv(data, format) {
  if (format.header) {
    data = format.header
      .map(stringValue)
      .join(format.delimiter) + '\n' + data;
  }
  return dsvFormat(format.delimiter).parse(data + '');
}
github d3 / d3-fetch / src / dsv.js View on Github external
export default function dsv(delimiter, input, init, row) {
  if (arguments.length === 3 && typeof init === "function") row = init, init = undefined;
  var format = dsvFormat(delimiter);
  return text(input, init).then(function(response) {
    return format.parse(response, row);
  });
}
github rstudio / leaflet / inst / htmlwidgets / lib / leaflet-omnivore / leaflet-omnivore.js View on Github external
delimiters.forEach(function (delimiter) {
        var res = dsv.dsvFormat(delimiter).parse(x);
        if (res.length >= 1) {
            var count = keyCount(res[0]);
            for (var i = 0; i < res.length; i++) {
                if (keyCount(res[i]) !== count) return;
            }
            results.push({
                delimiter: delimiter,
                arity: Object.keys(res[0]).length,
            });
        }
    });
github khartec / waltz / waltz-ng / client / common / file-utils.js View on Github external
export function downloadTextFile(dataRows = [],
                                 delimiter = ",",
                                 fileName = "download.csv") {
    const fileContent = dsv
        .dsvFormat(delimiter)
        .formatRows(dataRows);

    downloadFile(fileContent, fileName);
}
github mapbox / leaflet-omnivore / leaflet-omnivore.js View on Github external
delimiters.forEach(function (delimiter) {
        var res = dsv.dsvFormat(delimiter).parse(x);
        if (res.length >= 1) {
            var count = keyCount(res[0]);
            for (var i = 0; i < res.length; i++) {
                if (keyCount(res[i]) !== count) return;
            }
            results.push({
                delimiter: delimiter,
                arity: Object.keys(res[0]).length,
            });
        }
    });
github jupyterlab / jupyterlab / packages / csvviewer / src / table.ts View on Github external
private _parse(): void {
    this._data = dsv.dsvFormat(this._delimiter).parse(this._content);
  }
github mapbox / leaflet-omnivore / leaflet-omnivore.js View on Github external
function auto(x) {
    var delimiter = autoDelimiter(x);
    if (!delimiter) return null;
    return deleteColumns(dsv.dsvFormat(delimiter).parse(x));
}
github mhkeller / joiner / bin / io / formatters.js View on Github external
psv: function (file, writeOptions) {
    writeOptions = writeOptions || {}
    try {
      return dsv.dsvFormat('|').format(file, writeOptions.columns)
    } catch (err) {
      reportParseError('psv')
    }
  },
  txt: function (d) { return d },
github mapbox / csv2geojson / index.js View on Github external
delimiters.forEach(function (delimiter) {
        var res = dsv.dsvFormat(delimiter).parse(x);
        if (res.length >= 1) {
            var count = keyCount(res[0]);
            for (var i = 0; i < res.length; i++) {
                if (keyCount(res[i]) !== count) return;
            }
            results.push({
                delimiter: delimiter,
                arity: Object.keys(res[0]).length,
            });
        }
    });