GithubHelp home page GithubHelp logo

json-to-csv-converter's Introduction

JSON to CSV Converter

This is a simple local JavaScript function that converts a JSON file to a CSV file. It reads the JSON data from a file, flattens the JSON object, and generates a CSV file with keys in one column and values in another column.

Usage

Clone this repository and install the required dependencies by running npm install

Replace the placeholder JSON file path and CSV file path in the jsonToCsv function with your own file paths or update data.json content:

const csvFile = 'output_data.csv'
const jsonFile = './data.json'

Run the script by executing the following command:

npm run start

This will convert the JSON file to CSV and save it to the specified output file path.

Check the output CSV file in the specified file path. It should contain the keys in one column and the corresponding values in another column.

Notes

  • Make sure your input JSON file contains valid JSON data. Any syntax errors in the JSON file may cause the script to fail.

  • If your JSON file contains nested objects, the script will flatten them and include the nested keys as part of the CSV headers.

json-to-csv-converter's People

Contributors

dianavolt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.