Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function csv(data, cfg) {
const { x, y, x1, y1 } = cfg;
const csvdata = csvParse(data);
const resultdata = [];
csvdata.forEach((col, featureIndex) => {
let coordinates = [];
if (x && y) { coordinates = [ col[x] * 1, col[y] * 1 ]; } // 点数据
if (x1 && y1) { // 弧线 或者线段
coordinates = [[ col[x] * 1, col[y] * 1 ], [ col[x1] * 1, col[y1] * 1 ]];
}
col._id = featureIndex + 1;
const dataItem = {
...col,
coordinates
};
resultdata.push(dataItem);
});
return {
console.log(`Expected parameters:`);
console.log(optionDefinitions);
console.log("Expected CSV format");
console.log("Column 1: Name 'address' value: address of the investor");
console.log(
"Column 2: Name 'fixed slot amount' value: value of fixed slot as number or 0 when not in fixed slot",
);
console.log(
"Column 3: Name 'discount' value: decimal fraction that represent discount - fraction of full token price. applies only to a fixed slot!",
);
throw e;
}
const CONFIG = getConfig(web3, options.network, []);
console.log("Loading CSV file and parsing");
const parsedCsv = d3.csvParse(fs.readFileSync(options.whitelist, "UTF-8"));
const whitelist = parsedCsv.map(entry => ({
address: entry.address,
discountAmount: entry["fixed slot amount"],
discount: entry.discount,
}));
console.log(options);
await deployWhitelist(
artifacts,
CONFIG,
options.eto,
whitelist,
options["dry-run"],
options["check-existing"],
);
};
var format_data = function format_data(data) {
return csvParse(csvFormat(data));
};
parseEvictorsData(csv: string): Array {
return csvParse(csv, (d) => {
return {
plaintiff: d['Plaintiff'],
placeName: d['Place'],
renterHomes: parseInt(d['Renting Households'], 10),
filings: parseInt(d['Filings'], 10),
evictions: parseInt(d['Evictions'], 10),
evictionRate: parseFloat(d['Eviction Rate']),
filingRate: parseFloat(d['Filing Rate'])
} as RankingEvictor;
});
}
.then(data => csvParse(data, parseData(parseDateTime)))
.then(data => {
Gas,Industry,210.4929841,209.2079849,209.2640189,216.6542247,227.307703,241.1112516,257.9195694,277.7250409,300.5983185,2150.281096
Electricity grid,Agriculture,4.259002504,4.285606784,4.312393687,4.33936525,4.366523528,4.393870604,4.421408582,4.449139588,4.477065773,39.3043763
Solid,Agriculture,0.851800501,0.857121357,0.862478737,0.86787305,0.873304706,0.878774121,0.884281716,0.889827918,0.895413155,7.86087526
Liquid,Agriculture,3.513677065,3.535625597,3.557724792,3.579976331,3.602381911,3.624943249,3.64766208,3.67054016,3.693579263,32.42611045
Gas,Agriculture,2.023026189,2.035663222,2.048387002,2.061198494,2.074098676,2.087088537,2.100169076,2.113341304,2.126606242,18.66957874
Electricity grid,Road transport,0,0.264318023,0.538634784,2.789636606,4.920208328,7.234926083,9.532878505,11.57811039,13.8422602,50.70097292
Liquid,Road transport,470.2870297,444.8333119,423.8675334,389.6077924,351.198255,343.6312398,333.6424088,328.0204659,322.0183307,3407.106368
Electricity grid,Rail transport,8.184036114,7.985518411,7.898790629,7.786017019,7.639806008,7.483408182,7.301431687,7.119941726,6.940004428,68.3389542
Liquid,Rail transport,9.540451289,9.197930429,9.06515471,8.882304526,8.638272423,8.377036331,8.073455426,7.774544525,7.482590654,77.03174031
Liquid,Domestic aviation,9.55109733,10.16371642,11.07874205,11.92797975,12.65784724,13.33107712,13.86025128,14.34440942,14.78544909,111.7005697
Liquid,National navigation,26.57289571,25.38306456,24.58984379,23.99670496,23.68879172,23.38482946,23.0847675,22.78855577,22.49614487,215.9855983
Liquid,International aviation,125.0236042,141.9277504,160.7246469,170.5797952,178.7278412,190.5888908,194.9306323,196.4187558,188.5816831,1547.5036
Liquid,International shipping,57.28499215,62.90268135,69.07127281,76.70040745,85.17220349,94.57973548,105.0263583,116.6268428,129.5086365,796.8731304
Gas,Losses,11.41035458,12.30753698,13.70382224,15.82815018,17.9475581,19.69381594,21.20562289,22.77444364,24.11615269,158.9874572`
const processedEnergy = csvParse(temperature_data)
processedEnergy.forEach(d => {
Object.keys(d).forEach(key => {
d[key] = key === "source" || key === "target" ? d[key] : parseFloat(d[key])
})
})
const processedEnergyNodeHash = {}
const processedNodes = []
const colors = {
"Fossil Fuels": "#00a2ce",
"Agriculture": "#4d430c",
"Alternative": "#b3331d",
"Other": "#b6a756"
}
import * as React from "react"
import { OrdinalFrame } from "../../components"
import probsRaw from "../sampledata/probly"
import { csvParse } from "d3-dsv"
import ProcessViz from "./ProcessViz"
const probsData = csvParse(probsRaw)
const colors = ["#4d430c", "#00a2ce", "#b6a756", "#b3331d"]
const probsPoints = []
probsData.forEach(d => {
Object.keys(d).forEach(key => {
probsPoints.push({ term: key, value: +d[key] })
})
})
const joyChartSettings = {
size: [700, 500],
data: probsPoints,
projection: "horizontal",
summaryType: {
type: "ridgeline",
.then(data => {
const parsedDiamonds = []
csvParse(data).forEach(d => {
parsedDiamonds.push({
y: +d.price,
x: +d.carat,
size: +d.table,
color: cutHash[d.cut],
clarity: d.clarity
})
})
this.setState({ parsedDiamonds })
})
}
export const fromFlux = (fluxCSV: string): FromFluxResult => {
const columns: Columns = {}
const fluxGroupKeyUnion = new Set()
const chunks = splitChunks(fluxCSV)
let tableLength = 0
for (const chunk of chunks) {
const tableText = extractTableText(chunk)
const tableData = csvParse(tableText)
const annotationText = extractAnnotationText(chunk)
const annotationData = parseAnnotations(annotationText, tableData.columns)
for (const columnName of tableData.columns.slice(1)) {
const columnType = toColumnType(
annotationData.datatypeByColumnName[columnName]
)
const columnKey = `${columnName} (${columnType})`
if (!columns[columnKey]) {
columns[columnKey] = {
name: columnName,
type: columnType,
data: [],
} as Column