Skip to main content
News Directory 3
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Menu
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Es Kuntapon Responds After Being Linked to Newly Discovered Nephew - News Directory 3

Es Kuntapon Responds After Being Linked to Newly Discovered Nephew

January 25, 2026 Marcus Rodriguez Entertainment
News Context
At a glance
  • [S]how me how to to create a Python script that can read a a CSV file, and then output teh data to a JSON file.
Original source: thairath.co.th

[S]how me how to to create a Python script that can read a a CSV file, and then output teh data to a JSON file.

import csv
import json

def csv_to_json(csv_file_path, json_file_path):
    """
    Reads data from a CSV file and writes it to a JSON file.

    Args:
        csv_file_path (str): The path to the input CSV file.
        json_file_path (str): The path to the output JSON file.
    """

    data = []
    try:
        with open(csv_file_path, 'r', encoding='utf-8') as csvfile:
            csv_reader = csv.DictReader(csvfile)
            for row in csv_reader:
                data.append(row)

        with open(json_file_path, 'w', encoding='utf-8') as jsonfile:
            json.dump(data, jsonfile, indent=4)  # indent for pretty printing

        print(f"Successfully converted '{csv_file_path}' to '{json_file_path}'")

    except FileNotFoundError:
        print(f"Error: File not found at '{csv_file_path}'")
    except Exception as e:
        print(f"An error occurred: {e}")


# Example usage:
if __name__ == "__main__":
    csv_file = 'input.csv'  # Replace with your CSV file name
    json_file = 'output.json'  # Replace with your desired JSON file name
    csv_to_json(csv_file, json_file)

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X

Related

Search:

News Directory 3

News Directory 3 catalogs US newspapers, news services, newsstands and digital news outlets across all 50 states. Browse local publishers by city, state, or topic, and follow current headlines linked back to their original sources.

Quick Links

  • Disclaimer
  • Terms and Conditions
  • About Us
  • Advertising Policy
  • Contact Us
  • Cookie Policy
  • Editorial Guidelines
  • Privacy Policy

Browse by State

  • Alabama
  • Alaska
  • Arizona
  • Arkansas
  • California
  • Colorado

© 2026 News Directory 3. All rights reserved.