file2jsonjs
A simple Node.js package for reading CSV, Excel, and TXT files with flexible options, inspired by Python's pandas.
Features
- Read CSV, Excel (.xlsx), and TXT files
- Flexible options: custom headers, delimiter, skip lines, skip empty lines
- Returns JSON array of objects mapped to headers
Usage
const { readCSV, readExcel, readTxt } = require('file2jsonjs');
const data = await readCSV({ filePath: 'data.csv', headers: ['col1', 'col2'], delimiter: ',', skipLines: 1, skipEmptyLines: true });
API
readCSV(options)
readExcel(options)
readTxt(options)
All options are optional:
filePath (string): Path to the file
headers (array): Array of header names
delimiter (string): Delimiter for CSV/TXT
skipLines (number): Number of lines to skip at the start
skipEmptyLines (boolean): Skip empty lines
License
MIT