danfo.streamCsvTransformer
A pipeline transformer to stream a CSV file from local storage, transform it with a custom transformer, and write to the output stream. Only available in Node.js
Parameters
Type
Description
Stream processing a local file
import { DataFrame, Series, streamCsvTransformer } from "danfojs-node";
import path from "path"
const inputFilePath = path.join(process.cwd(), "raw_data", "titanic.csv");
const outputFilePath = path.join(process.cwd(), "raw_data", "titanicOutLocal.csv");
/**
* A simple function that takes a DataFrame, and transforms the Name column.
* */
const transformer = (df) => {
const titles = df["Name"].map((name) => name.split(".")[0]);
const names = df["Name"].map((name) => name.split(".")[1]);
df["Name"] = names
df.addColumn("titles", titles, { inplace: true })
return df
}
dfd.streamCsvTransformer(inputFilePath, transformer, {
outputFilePath,
inputStreamOptions: { header: false }
})Stream processing of remote file
Stream processing with a custom writer
Last updated