本文整理汇总了TypeScript中d3-dsv.csvFormat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript csvFormat函数的具体用法?TypeScript csvFormat怎么用?TypeScript csvFormat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了csvFormat函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
length: rr[3].length ? +rr[3] : NaN
}
: undefined
)
: null;
return pr;
});
dateNull = parseRowsMappedArray[0].year;
strMaybe = parseRowsMappedArray[0].make;
strMaybe = 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 ? d.year.getFullYear().toString() : '',
d.make,
d.model,
d.length.toString()
]));
// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------
示例2: Date
d > 1997
? {
year: new Date(d, 0, 1),
make: rr[1].length ? rr[1] : "Missing Value",
model: rr[2].length ? rr[2] : "Missing Value",
length: rr[3].length ? +rr[3] : NaN
}
: undefined
)
: null;
return pr;
});
// csvFormat(...) ============================================================================
str = d3Dsv.csvFormat(parseRowsMappedArray);
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "length"]);
str = d3Dsv.csvFormat(parseRowsMappedArray, ["year", "unknown"]); // $ExpectError
// csvFormatRows(...) ========================================================================
str = d3Dsv.csvFormatRows(parseRowsMappedArray.map((d) => [
d.year ? d.year.getFullYear().toString() : '',
d.make,
d.model,
d.length.toString()
]));
// ------------------------------------------------------------------------------------------
// Test TSV
// ------------------------------------------------------------------------------------------
示例3: tally
for (const row of airlines) {
tally(info.airportDict, row.airport.code, row.airport);
tally(info.carrierDict, row.carrier.code, row.carrier);
const timeParts = row.time.label.split("/");
info.stats.push({
year: timeParts[0],
month: timeParts[1],
airport: row.airport.code,
carrier: row.carrier.code,
ontime: row.statistics.flights["on time"],
cancelled: row.statistics.flights.cancelled,
delayed: row.statistics.flights.delayed,
diverted: row.statistics.flights.diverted,
delay: row.statistics["minutes delayed"].total
});
}
for (const key in info.airportDict) {
info.airports.push(info.airportDict[key]);
}
for (const key in info.carrierDict) {
info.carriers.push(info.carrierDict[key]);
}
fs.writeFile("data/airports.csv", csvFormat(info.airports), "utf8", () => { });
fs.writeFile("data/carriers.csv", csvFormat(info.carriers), "utf8", () => { });
fs.writeFile("data/stats.csv", csvFormat(info.stats), "utf8", () => { });