Skip to content

KiwiGolden-rs/Data_Formatting_CSV_to_JSON_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Data_Formatting_CSV_to_JSON_Python

This repository contains a simple Python script that demonstrates how to read client data from a CSV file, process it, and generate JSON output.

πŸ“‹ Overview

Learning simple data formatting in Python from CSV file into JSON file.

This script:

  • Reads a CSV file containing client information,
  • Calculates additional fields (e.g., applying VAT),
  • Builds a JSON structure for each client,
  • Prints the JSON output to the console (for testing and debugging).

πŸš€ Features

βœ… Reads CSV input line by line
βœ… Processes data and calculates a new field (amount with VAT)
βœ… Outputs JSON objects (one per client)


πŸ—οΈ Requirements

  • Python 3.8+
  • No external dependencies (only built‑in libraries: csv and json)

πŸ“‚ Input File Format

The script expects a clients.csv file in the same directory, with at least the following columns:

Column name Description Example
name Client’s full name John Doe
channel Preferred channel (email or paper) email
amount_ht Base amount (without VAT) 250.75

Example clients.csv:

name,channel,amount_ht
John Doe,email,250.75
Jane Smith,paper,120.00

The script will output a JSON object per line in the console:

{"clientName": "John Doe", "preferredChannel": "email", "amount": 300.9}
{"clientName": "Jane Smith", "preferredChannel": "paper", "amount": 144.0}

πŸ’‘ Customization

If you want to save the JSON output to a file, you can delete or comment the print(...) line and uncomment the following lines:

#results = []
#results.append(output)
#with open('output.json', 'w', encoding='utf-8') as json_file:
#    json.dump(results, json_file, ensure_ascii=False, indent=4)

πŸ“„ License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages