A simple script to convert .xlsx file to .csv file, with the ability to filter / rename columns.
A simple script to convert .xlsx file to .csv file, with the ability to filter / rename columns.
To install, run the following command in your terminal:
npm install xlsx-to-csv-ts
To use xlsx-to-csv-ts
in your Node.js project, you need to import it as follows:
import { convertXlsxToCsv } from "xlsx-to-csv-ts";
const result = await convertXlsxToCsv({
inputFile: "./public/sample.xlsx",
outputFilename: "sample-filtered",
outputDir: "./public/",
filter: { Segment: "segment", Country: "country" }, // Format: { "original column": "renamed column", ... }
});
console.log(result.outputPath)