sample-go-json2excel

This is a sample project to convert json to excel.

Sample Cases

This sample loads a big json file and convert it to excel.

This project tries 3 cases for combination of loading and converting methods.

Case# Loading JSON Converting JSON to Excel Generating intermediate objects
Case 1 batch stream yes
Case 2 stream stream yes
Case 3 stream stream no

Code of each case is in the following files.

The data in the JSON file is as follows.

  • a user has the following fields.
    • Name(string)
    • Age(int)
    • Profile(string)
  • 1000000 users

Results

The pprof results in the three cases are as follows.

- Case 1 Case 2 Case 3
Used memory 238.05MB 257.08MB 20MB
Time 4.005241083s 3.959007833s 3.859536417s
pprof mem1 prof mem2 prof mem3 prof

How to run

Prerequisites

Generate the input JSON file by running the following command.

make gen-userlist

Run

make memp{case#} runs the sample.

For example, to run Case 1, run the following command.

make memp1

To run all cases, run the following command.

make memp_all