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

excelcsv

v0.1.2

Published

Parse an excel workbook, and all its worksheets, into a single CSV file.

Downloads

516

Readme

ExcelCSV

Parse an excel workbook (.xlsx), and all its worksheets, into a single CSV file, and transform the output.

I wrote ExcelCSV to solve this problem:

A client needed some black magic to transform a massive excel workbook, with hundreds of worksheets, into a single CSV, to eventually import the CSV into a database. Messy, I know. Unfortunately, excel does not have native support for exporting a collection of worksheets as a CSV. There are plenty of other excel parsers out there, but most of them only help you read data, when I needed to both read and transform my data.

Installation

npm install excelcsv

or

git clone https://github.com/Moonfuse/excelcsv.git
cd excelcsv
npm install

Features

  • Preprocess each row
    • Transform data
    • Ignore data
  • Append a header

Example

var ExcelCSV = require('excelcsv');

var header  = ['id', 'email']
  , fileIn  = 'src/example.xlsx'
  , fileOut = 'dist/example.csv';

// fileOut is optional.
var parser = new ExcelCSV( fileIn, fileOut );
var csv = parser
            // optional.
            .header( header )
            // optional.
            .row(function(worksheet, row) {
              // Transform data here or return false to skip the row.
              return row;
            })
            .init();

Methods

init()

Runs the script and returns the CSV as a string.

header( Array )

[optional] Append a header to the beginning of the CSV.

row( callback(Array row, String worksheetName) )

[optional] Preprocess your data.

The callback accepts two parameters:

  • row (Array)
  • worksheetName (String)

Row values are not modified by reference, so you must return an array w/ the desired output for each row, or false to skip the row altogether.

worksheetName can be useful for adding extra data to your rows

Appendix

Approaches

It should be known, that there are other ways to solve this problem.

  • If your're a VB guy, you can write a excel macro and export your data as a XML file, and perhaps a CSV.
  • Excel for Windows, has functionality that allows you to attach an XML schema, map cells to said schema, and eventually export and XML file.

Maintenance

Feedback is most welcome; if you want to help make improvements, fork and pull, file an issue, or shoot [email protected] an email.