@kochtaik/csv-to-json-parser
v1.0.2
Published
This small CSV parser is able to convert valid CSV files into JSON. It is compatible with the most common separators (commas, tabs, semicolons). The parser was made for the learning purposes. Please, don't use it for your projects.
Downloads
1
Readme
Csv to json parser
Short Description
You need to build a command line tool which allows the user to convert CSV files to JSON.
Topics
- Core Concept
- Event Loop
- Globals
- Modules
- Streams
- Async Operations
- NPM
- Network
Requirements
You need to build an npm package for parsing CSV files to JSON by implementing a custom NODE.js transform stream with the following abilities:
- Set or automatically detect the separator that is used for parsing (use "auto-detect" by default if no separator provided)
- Upload result JSON file to Google Drive disk
- Provide errors handling for converting process and incorrect command line arguments.
This application should accept following command line arguments using process.argv:
"sourceFile" - path to the csv file that need to be converted.
"resultFile" - path to the result json file.
"separator" - separator that is used while converting.
An example of running the app with command line arguments:
- node csvToJson.js --sourceFile "source.csv" --resultFile "result.json" --separator ","
- node csvToJson.js --sourceFile "source.csv" --resultFile "result.json" --separator " "
- node csvToJson.js --sourceFile "source.csv" --resultFile "result.json"
If you want to upload file to the Google Drive, please, do the following steps:
- Get your credentials from the Google Cloud console. They must include client ID, client secret, redirect URL and refresh token. Create a .env file and save them under next variables (respectively): GOOGLE_DRIVE_CLIENT_ID, GOOGLE_DRIVE_CLIENT_SECRET, GOOGLE_DRIVE_REDIRECT_URI, GOOGLE_DRIVE_REFRESH_TOKEN.
- Run the script with the argument
--uploadToGDrive
. The file will appear in your Google Drive, under "JSON-to-CSV parser" folder.
Testing
Write a function that generates at least 10 gigabyte CSV file base on the filled in with mock csv file Generate a CSV file and use it as an source file for your tool. When running the parser pay attention to the RAM that is taken by the process.
Publishing
Add version, name, description, and author of the package in package.json. Publish the package you created to the npm registry.
Advanced Requirements
- Implement JSON to CSV parser.