This Node.js script converts a CSV file into a JSON file using the csv-parser
and fs
modules.
-
Clone this repository or download the
index.js
file. -
Ensure you have Node.js installed on your system.
-
Install the required npm packages by running the following command in your terminal:
npm install csv-parser
-
Place the CSV file you want to convert in the
sample-data
directory. -
Open the
index.js
file and modify thefilePath
variable to specify the path to your CSV file. -
Optionally, update the
fieldsOfFiles
array to match the fields/columns of your CSV file. -
Run the script by executing the following command in your terminal:
node index.js
-
After the script finishes executing, a JSON file containing the converted data will be created in the
sample-data
directory with the same name as the CSV file, but with a.json
extension.
- csv-parser: Used to parse CSV files.
- fs: Node.js file system module for file operations.
This project is licensed under the MIT License - see the LICENSE file for details.