npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@imrandil/csv-to-excel-converter

v1.0.1

Published

A simple npm package for converting CSV files to Excel (XLSX) format efficiently using streams.

Downloads

120

Readme

CSV to Excel Converter

A simple and efficient Node.js module for converting CSV files to Excel (XLSX) format using streams. This package leverages the power of csv-parser and exceljs libraries to handle large datasets efficiently without consuming too much memory.

Features

  • Stream-based processing: Efficiently handles large CSV files.
  • Optional header support: Use your own header or extract from CSV data.
  • Easy-to-use API: Simple function call to convert your CSV to Excel.

Installation

npm install @imrandil/csv-to-excel-converter

Usage

Basic Usage

const csvToExcel = require('@imrandil/csv-to-excel-converter');

const header = null; // Use null to extract headers from the CSV file
const inputFilePath = './path/to/input.csv';
const outPutFilePath = './path/to/output.xlsx';

csvToExcel(header, inputFilePath, outPutFilePath);

With Custom Headers

const csvToExcel = require('@imrandil/csv-to-excel-converter');

const header = [
  { header: 'id', key: 'id', width: 15 },
  { header: 'is_active', key: 'is_active', width: 10 },
  { header: 'created_date', key: 'created_date', width: 25 },
  { header: 'last_modified_date', key: 'last_modified_date', width: 25 },
  { header: 'unique_id', key: 'unique_id', width: 20 },
    // add more headers as needed
];
const inputFilePath = './path/to/input.csv';
const outPutFilePath = './path/to/output.xlsx';

csvToExcel(header, inputFilePath, outPutFilePath);

Parameters

  • header: An array of objects containing headers (optional). If not provided, headers will be extracted from the CSV file.
  • inputFilePath: The path to the input CSV file (required).
  • outPutFilePath: The path to the output Excel file (required).

Example Use Cases

1. Data Migration

Easily migrate data from legacy systems that export data in CSV format to systems that accept Excel files.

2. Data Reporting

Generate Excel reports from CSV data for better readability and data manipulation.

3. Data Analysis

Convert CSV files from data analysis tools into Excel format for further analysis with tools like Excel or Google Sheets.

Error Handling

The module performs validation on input and output paths and provides meaningful error messages for the user.

try {
    csvToExcel(header, inputFilePath, outPutFilePath);
} catch (error) {
    console.error('Error processing CSV to Excel:', error.message);
}

Contributions

Contributions are welcome! Please submit a pull request or open an issue to discuss improvements or features.

License

This project is licensed under the MIT License.


With this package, converting CSV files to Excel format is a breeze. It efficiently handles large datasets and offers flexibility with optional headers. Perfect for data migration, reporting, and analysis!


Repository

For more information, issues, or contributions, visit our GitHub repository.

Author

Developed by Ali Imran Adil.


Support

If you have any questions or need support, feel free to open an issue on GitHub.