How to use the d3-dsv.csvFormat 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 DefinitelyTyped / DefinitelyTyped / d3-dsv / d3-dsv-tests.ts View on Github external
model: rr[2],
        length: +rr[3]
    };

    return pr;

});

date = parseRowsMappedArray[0].year;
str = parseRowsMappedArray[0].make;
str = parseRowsMappedArray[0].model;
num = parseRowsMappedArray[0].length;

// csvFormat(...) ============================================================================

str = d3Dsv.csvFormat(parseRowsMappedArray);
str = d3Dsv.csvFormat(parseRowsMappedArray, columns);

// csvFormatRows(...) ========================================================================

str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
    d.year.getFullYear().toString(),
    d.make,
    d.model,
    d.length.toString()
]));

// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------

// tsvParse(...) ============================================================================
github DefinitelyTyped / DefinitelyTyped / d3-dsv / d3-dsv-tests.ts View on Github external
length: +rr[3]
    };

    return pr;

});

date = parseRowsMappedArray[0].year;
str = parseRowsMappedArray[0].make;
str = parseRowsMappedArray[0].model;
num = parseRowsMappedArray[0].length;

// csvFormat(...) ============================================================================

str = d3Dsv.csvFormat(parseRowsMappedArray);
str = d3Dsv.csvFormat(parseRowsMappedArray, columns);

// csvFormatRows(...) ========================================================================

str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d, i) => [
    d.year.getFullYear().toString(),
    d.make,
    d.model,
    d.length.toString()
]));

// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------

// tsvParse(...) ============================================================================
github digidem / mapeo-desktop / src / renderer / components / MapFilter / DataExportDialog.js View on Github external
return {
      ID: i + 1,
      MAPEO_ID: o.id,
      DATE: formatCsvDate(o.created_at),
      TIME: formatCsvTime(o.created_at),
      COMMENT: o.tags.notes || o.tags.note,
      PHOTOS,
      ...locationData
    }
  })

  // We do this to order the columns of the CSV, otherwise csvFormat column
  // order is non-deterministic
  const columns = 'ID,X,Y,DATE,TIME,COMMENT,PHOTOS,MAPEO_ID'.split(',')

  return csvFormat(rows, columns)
}
github digidem / mapeo-desktop / src / renderer / components / MapFilter / DataExportDialog.js View on Github external
// We do this to order the columns of the CSV, otherwise csvFormat column
  // order is non-deterministic
  const columns = [
    '$id',
    '$created',
    '$modified',
    '$lon',
    '$lat',
    '$utmX',
    '$utmY',
    '$utmZone',
    '$photos'
  ].concat(Object.keys(allKeys).sort(), '$version')

  return csvFormat(rows, columns)
}
github medialab / ricardo_data / importApp / src / redux / modules / repoData.js View on Github external
type: UPDATE_REMOTE_FILES_LOG,
            payload: `downloading existing flows file ${file.fileName}`
          });
          const exists = await get(`${repoRawContent}/${branch}/data/${file.fileName}`,{ responseType: 'text', responseEncoding: 'utf8'})
          if (exists.status === 200) {
            // append new rows at end of the existing file
            file.data = csvParse(exists.data).concat(file.data) 
          }
          // else it's a new file nothing to do
          // actually yes we should update datapackage see issue #70
        }
        dispatch({
          type: UPDATE_REMOTE_FILES_LOG,
          payload: `uploading ${file.fileName}`
        });
        let fileGit = await repo.git.blobs.create({content: Base64.encode(csvFormat(file.data)), encoding: 'base64'});
        let filePath = `data/${file.fileName}`;
        treeItems.push({
          path: filePath,
          sha: fileGit.sha,
          mode: "100644",
          type: "blob"
        })
      } 
      dispatch({
        type: UPDATE_REMOTE_FILES_LOG,
        payload: `creating tree`
      });
      let tree = await repo.git.trees.create({
        tree: treeItems,
        base_tree: baseReference.object.sha
      });
github orbiting / republik-frontend / components / Card / MyList.js View on Github external
onClick={e => {
            const url = (e.target.href = URL.createObjectURL(
              new window.Blob(
                [
                  csvFormat(
                    withCards.map(s => ({
                      status: s.dir === 1 ? 'folgen' : 'ignorieren',
                      name: s.card.user.name,
                      partei: s.card.payload.party,
                      jahrgang: s.card.payload.yearOfBirth,
                      reoublikLink: `https://www.republik.ch/~${s.card.user.slug}`,
                      smartvoteLink:
                        s.cardCache.payload.councilOfStates.linkSmartvote ||
                        s.cardCache.payload.nationalCouncil.linkSmartvote
                    }))
                  )
                ],
                { type: 'text/csv' }
              )
            ))
            setTimeout(function() {
github mhkeller / indian-ocean / lib / index.js View on Github external
csv: function (file, writeOptions) {
    writeOptions = writeOptions || {}
    file = formattingPreflight(file, 'csv')
    try {
      return dsv.csvFormat(file, writeOptions.columns)
    } catch (err) {
      reporters.parseError('csv')
    }
  },
  tsv: function (file, writeOptions) {
github tensorflow / tfjs-examples / intent-classifier / training / raw_to_csv.js View on Github external
function writeCSV(data, path) {
  const csvStr = dsv.csvFormat(data, ['query', 'intent']);
  fs.writeFileSync(path, csvStr, {encoding: 'utf8'});
}
github orbiting / republik-frontend / components / Questionnaire / Results.js View on Github external
onClick={e => {
            const url = (e.target.href = URL.createObjectURL(
              new window.Blob([csvFormat(props.values)], { type: 'text/csv' })
            ))
            setTimeout(function() {
              URL.revokeObjectURL(url)
            }, 50)
          }}
        >
github orbiting / publikator-frontend / components / editor / modules / chart / EditOverlay.js View on Github external
onPaste: e => {
                  const clipboardData = e.clipboardData || window.clipboardData
                  let parsedTsv
                  try {
                    parsedTsv = tsvParse(clipboardData.getData('Text'))
                  } catch (e) {}
                  if (parsedTsv && parsedTsv.columns.length > 1) {
                    e.preventDefault()
                    onChange(data.set('values', csvFormat(parsedTsv)))
                  }
                }
              })}