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

csv-reorder

v0.1.1

Published

csv-reorder is a small library that makes it easy to reorder the rows on a csv file given a column name. It can be used both as a command line utility, as well as a standalone node.js library.

Downloads

70

Readme

csv-reorder

csv-reorder is a small library that makes it easy to reorder the rows on a csv file given a column name. It can be used both as a command line utility, as well as a standalone node.js library.

Requirements

csv-reoder requires node.js@^6.x.x, as well as npm@^4.x.x or Yarn.

CLI Usage

Installation

To install the cli globally, from npm:

npm install -g csv-reorder

Or downloading and running locally:

npm install -g

Options

Input and Output

--input <path to file> --output <path to output>

alternatively, using the short form:

-I <path to file> -O <path to output>

The output file cannot be the same as the input file.

Sort order

In order for the rows to be sorted, csv-reorder must be given a column name:

--sort <column name>

or, in its short form

-S <column name>

Occasionally, a user might want to sort the rows by a property that shouldn't be interpreted as a string. In that case, the argument sort-type should be given:

--sort-type <type: 'number', 'date', 'boolean', 'string' (default)>

or

-T <...>

Sorting can also be set as ascending (default) or descending:

--ascending, which is equivalent to -A

or

--descending, equivalent to -D

Remove duplicate rows

A .csv document may contain duplicate rows. In order to remove duplicate rows from the final output file, use the following flag:

--remove-duplicates or -R

Metadata and stats output

csv-reorder will output statistics about the operation unless told otherwise. For no output, use:

--silent or -Q

Help

For an explanation of each cli flag, run the command:

csv-reorder --help

Standalone Library

As an alternative, csv-reorder can also be used as a standalone library.

Install csv-reorder with npm:

npm install csv-reorder --save

or, if you're using Yarn

yarn add csv-reorder

Usage

Example script:

const reorder = require('csv-reorder');

reorder({
  input: './file.csv',
  output: './output.csv',
  sort: 'Launch Date',
  type: 'date',
  descending: false,
  remove: true,
  metadata: false
})
.then(metadata => {
  // ...
})
.catch(error => {
  // ...
});

Known issues

Due to limitations in the csv specification, it is possible for valid csv files not to include a table header as it's first row. csv-reorder will always consider the first row to be a table header, and behave accordingly.

License

MIT