This project is a simple Go module that converts CSV files to JSON format. The program reads a CSV file, processes its content, and outputs the result as a JSON file.
These instructions will help you set up the project on your local machine for development and testing purposes.
- Go (version 1.14+)
-
Clone the repository:
sh
Copy code
git clone https://github.com/guilhermemcardoso/gotransform.git cd gotransform
-
Build the project:
go build -o gotransform
To use the CSV to JSON converter, run the following command:
sh
Copy code
./gotransform <yourfile.csv>
This command will generate a JSON file with the same name as the input CSV file, but with a .json
extension.
Suppose you have a CSV file named example.csv
. To convert it to JSON, use:
./gotransform example.csv
The program will create a file named example.json
containing the JSON representation of the CSV data.
The main logic of the program is in the main.go
file. The process is as follows:
- Read the CSV file:
- The CSV file is opened and read using the
encoding/csv
package.
- The CSV file is opened and read using the
- Process the CSV content:
- The first row is considered as headers.
- Each subsequent row is converted into a JSON object using the headers as keys.
- Write to a JSON file:
- The JSON data is written to a new file with a
.json
extension.
- The JSON data is written to a new file with a
If you have suggestions for improving this project, feel free to submit a pull request or open an issue.