siesvi
is a lightweight yet powerful CSV processing library designed for Node.js. It provides essential functionalities for handling CSV files efficiently by leveraging the power of Node.js streams. This makes it suitable for processing large datasets without excessive memory consumption.
The library offers a high-level wrapper class for ease of use, as well as lower-level stream-based classes for more advanced or customized processing pipelines.
npm i @maukode/siesvi
Important: don't forget scope @maukode
, so full name of this package is @maukode/siesvi
siesvi
consists of two main types of components:
- Wrapper Class – A high-level abstraction that simplifies working with CSV files by managing the entire lifecycle, from loading to writing.
- Stream-Based Classes – Individual stream components that allow fine-grained control over CSV processing, useful for building custom pipelines.
The Csv
class provides a simple and convenient way to handle CSV files. It acts as a wrapper around the available stream-based classes, managing the entire workflow from reading a CSV file to processing and writing it back.
If you need a straightforward approach to handling CSV files, this class is the best choice. However, if you require more flexibility or need to build a custom pipeline, you can use the stream-based classes directly.
These classes extend Node.js stream modules and are designed for handling specific stages of CSV processing. They can be used individually or combined in a pipeline for greater control.
- This class reads a CSV file and converts it into a stream.
- It is the entry point for most CSV processing pipelines in
siesvi
.
- Performs validation on the incoming CSV stream.
- Helps ensure that data meets the expected format before further processing.
- Converts a validated CSV stream into structured JavaScript objects with the format:
{ [key: string]: number | string | boolean | Date }
- Important: This class does not perform CSV format validation. To avoid processing errors, it is recommended to place
CsvValidator
beforeCsvParser
in the processing pipeline.
- Transforms a processed stream into a CSV-formatted file.
- Supports two output methods:
- Writing directly to a file – Recommended for large datasets.
- Saving to an internal buffer – Useful for temporary storage but not recommended for large data, as it may cause out-of-memory errors.
- If you need a simple and efficient way to work with CSV files, use the
Csv
class. - If you require more flexibility, build a custom pipeline using
FileLoader
,CsvValidator
,CsvParser
, andCsvWriter
as needed. - Always validate CSV files before parsing them to prevent format-related issues.
- Avoid using an internal buffer for large datasets to prevent memory overflow.