Code Monkey home page Code Monkey logo

go_json_to_csv's Introduction

Parsing JSON to CSV in Golang

This is a demo repo to demonstrate how to use Golang to parse JSON files into CSV file. I also used Golang to generate the volume of JSON files (10,000). It read 10,000 of rows data entries from a CSV file and created corresponding JSON files. I also prepared a Python version to parse JSON files into CSV file for performance comparison.

Content:

  • /data/ <-- Folder to store input JSON files.
  • to_json.csv <-- Source CSV files for JSON files generation.
  • csv_to_json.go <-- Golang progrm to read 10,000 of rows data entries from a CSV file and created corresponding JSON files. It can directly run by "go run .\csv_to_json.go". Or build this Golang program by "go build .\csv_to_json.go" as exe to run.
  • json_to_csv.go <-- Golang program to parse JSON files into CSV file. It can directly run by "go run .\json_to_csv.go". Or build this Golang program by "go build .\json_to_csv.go" as exe to run.
  • json_to_csv.py <-- Python script to parse JSON files into CSV file.
  • json_to_csv_parallel.py <-- Optimized Python script to parse JSON file into CSV file with multiprocessing pool.

Performance comparison with Golang and Python

On average, compiled Golang program is 4 times faster than the Python script. alt text

Performance reference of optimized Python with multiprocessing pool

On average, optimized Python with a multiprocessing pool is 4 times faster than script without optimization. It is almost on par with compiled Golang program. alt text

Enjoy!

go_json_to_csv's People

Contributors

easonlai avatar

Stargazers

 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.