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-for-you

v1.0.6

Published

CSV parser. Supports all nodeJS versions.

Downloads

170

Readme

csv-for-you

This npm package is used by nodeJS developers for parsing CSV files into JSON objects, arrays numbers or strings. If you liked the package please star and follow me on GitHub

Installation

  1. Run npm install csv-for-you.
  2. Fork the git repository https://github.com/Minka1902/csv-for-you.git, and place it next to your project.

Usage

  1. In your entry point, import parseCsv from the package: const parseCsv = require('csv-for-you');
  2. Define your function as follows:
    const parseCsv = require('csv-for-you');
    const defaultOptions = {
        arraySeparator: ';',
        objectSeparator: ';',
        lineAsArray: true,
        fileAsArray: true,
        returnAsString: []
    };
    const options2 = {
        arraySeparator: '|',
        objectSeparator: '^',
        lineAsArray: false,
        fileAsArray: true,
        returnAsString: ['name', 'ID']
    };

    async function myFunction() {
        const myCsvFileData = await parseCsv('C:\\path\\to\\my\\file.csv', defaultOptions );
        const otherCsvFileData = await parseCsv('C:\\path\\to\\other\\file.csv', options2 );
        // Use the data however you'd like
    };

    const myOtherFunction = async () => {
        const myCsvFileData = await parseCsv('C:\\path\\to\\my\\file.csv', defaultOptions );
        const otherCsvFileData = await parseCsv('C:\\path\\to\\other\\file.csv', options2 );
        // Use the data however you'd like
    };

Options

This object contains the options for the CSV parser:

  1. arraySeparator - the Char that represents the separator between Array elements (; by default)
  2. objectSeparator - the Char that represents the separator between Object elements (; by default)
  3. lineAsArray - Boolean that represents rather a line should be represented as an Array or Object (true by default)
  4. fileAsArray - Boolean that represents rather the file should be represented as an Array or Object (true by default)
  5. returnAsString - Array of property names that should be returned as a string (empty by default)

Features

  1. Parses strings in CSV
  2. Parses numbers in CSV
  3. Parses arrays - numbers, strings, arrays and objects
  4. Parses objects - numbers, strings, arrays and objects

CSV file format

  1. Properties - The first line of the file must be the properties of the objects
  2. Numbers - Any integer or float number
  3. Strings - Strings of any length
  4. Arrays - Must start with [ and end with ] while the separator is not ,(arraySeparator in the options object to change)
  5. Objects - Must start with { and end with } while the separator is not ,(objectSeparator in the options object to change)
  6. Values are separated by , and nothing else!
  7. No need for whitespace after a coma - it might create problems

Future features

  1. Usage of callbacks for file/line/type of value
  2. Parsing text to JSON
  3. Fetching data from servers using URL
  4. Reading file structure starting from a folder
  5. Creating a CSV file from JSON object
  6. Error notifier - Lets you know what is the problem
  7. Generating numeric data to CSV or JSON
  8. Generating lingual data to CSV or JSON

Issues and Requests

For issues or feature requests go to https://github.com/Minka1902/csv-for-you/issues and add a new one. In the title write Request/Issue and elaborate in the description. I promise that i'll try my best to do everything.