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-json-parser-module

v1.0.7

Published

CSV to JSON parser

Downloads

18

Readme

Installation

npm i csv-json-parser-module

Development env

To invoke any module from scripts in package.json set

set NODE_ENV=development && node node_modules/csv-json-parser-module/src/FOLDER_NAME/FILE_NAME

then you can call module from the terminal with npm run SCRIPT_NAME command.

| FOLDER_NAME | main FILE_NAME | description | ------------- | ------------- | -------- | | bigFileCreator | bigFile | Creates file | | csvToJSON | csvParser | Parse file from csv to json | | google| googleApi| Uploads file to google drive|

IMPORTANT All field names apply to dev mode as well

Production env

Creating random csv file

Function creates random CSV file. Remember the size is approximate

Example invocation:

file name index.js
const parser = require('csv-json-parser-module');

parser.bigFile(process.argv);

process.argv is required as the params are taken from the terminal

Then you can call it in the terminal with:

node index filePath="FILE_PATH" size=SIZE

FILE_PATH is a place where you want to create CSV

Valid parameters

When passing the file path remember about commas around. Else it maybe split and cause error message

Size is considered in GB. If you want less take it under consideration

| value name | example value | type | isOptional| default value| | ------------- | ------------- | -------- |-------- |--------| | filePath | NAME.csv | string | true |C:/Users/YOUR_USER_NAME/Desktop/randomFile.csv| | size | 0.1 | number | true | 10GB|


Parse CSV to JSON

It is used to parse csv data to json. Program is not working in revers

Valid Parameters

When separator not passed its automatically searched. Basing on the first line e.g. header

| value name | example value | type | valid value/ extension | isOptional | ------------- | ------------- | -------- | -------- | -------- | | --sourceFile | "./testData/test.csv" | string | .csv | false | | --resultFile | "./testData/test.json"| string | .json | false | | --separator | "," | string | [' ', ',', ';'] | true |

Example invocation:

file name index.js
const parser = require('csv-json-parser-module');

(async () => {
  await parser.csvParser(process.argv)
  process.exit()
})();

The process needs to be stopped explicitly else it won't break by itself

Example Calls

node index -- --sourceFile "YOUR_INPUT" --resultFile "YOUR_OUTPUT" --separator "SEPARATOR"
node index -- --sourceFile "YOUR_INPUT" --resultFile "YOUR_OUTPUT"

Google Upload

Before running:

  1. Create .env file, and insert:
SCOPE = 'https://www.googleapis.com/auth/drive'
KEY_FILE_PATH = "./google/credentials/csv-to-json.json"
GOOGLE_FILE_ID = "GOOGLE_FILE_ID"

To get YOUR_GOOGLE_FILE_ID go to chosen directory in google drive and then take the part of url after folders/...

https://drive.google.com/drive/u/0/folders/YOUR_GOOGLE_FILE_ID
  1. Go under this link https://developers.google.com/drive/api/quickstart/nodejs and follow the Prerequisites instructions

  2. When received credentials paste it in chosen directory and pass path to KEY_FILE_PATH. Remember to get them as JSON file

Valid Parameters

| value name | example value | type | Extension | isOptional | ------------- | ------------- | -------- | -------- | -------- | | filePath | "./testData/test.csv" | string | .csv, .json | false |

Example invocation:

file name index.js
const parser = require('csv-json-parser-module');

(async () => {
  await parser.googleApi(process.argv)
  process.exit()
})();

The process needs to be stopped explicitly else it won't break by itself

Example Calls

node index filePath="YOUR_FILE_PATH"

REMEMBER Calls are just an example you can define them in scripts as well