Skip to main content
News Directory 3
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Menu
  • Business
  • Entertainment
  • Health
  • News
  • Sports
  • Tech
  • World
Military Doctor Concerned About Flu Season During Winter - News Directory 3

Military Doctor Concerned About Flu Season During Winter

January 14, 2026 Jennifer Chen Health
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 the data to a⁢ JSON file.
Original source: chiangmainews.co.th

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

import csv
import json

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

    Args:
        csv_file_path (str): the path to the 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 reading

  • New Cellular Mechanism May Explain Congenital Heart Defects
  • Eating One Avocado Daily Improves Heart Health

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.
For contact, advertising, copyright, issues email: office@newsdirectory3.com