This repository contains a Go program that converts data from Excel or CSV files to JSON or Markdown format.
By ruzhila.cn, a campus for learning backend development through practice.
🚀 100-line-code A collection of learning projects written in 100 lines of code
This is a tutorial code demonstrating how to use Golang for data transformation. Pull requests are welcome. 👏
The program takes two command-line arguments: the input file and the output file. It reads the data from the input file and writes it to the output file in the specified format. The format is determined by the file extension.
-
If the output file has a
.jsonextension, the program writes the data as an array of JSON objects. The keys of the objects are taken from the first row of the input file, and each subsequent row is written as a separate object. -
If the output file has a
.mdextension, the program writes the data as a Markdown table.
go run main.go input.xlsx output.json
go run main.go input.csv output.mdThis program uses the following Go libraries:
encoding/csvfor reading CSV filesencoding/jsonfor writing JSON filesosfor file operationspath/filepathfor handling file pathsgithub.com/qax-os/excelizefor reading Excel files