Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: create_example_csv.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- # For use with 'parity_number_counter.py': https://pastebin.com/KcCdq19X
- """
- Description:
- This script creates an example CSV file ('example.csv') with sample data.
- Requirements:
- - Python 3.x
- Usage:
- 1. Save this script as 'create_example_csv.py'.
- 2. Run the script.
- Note: Adjust the 'example_filename' variable in the script as needed.
- """
- import csv
- def create_example_csv(filename):
- # Define the data to be written to the CSV file
- data = [
- ['Name', 'Age', 'City', 'Salary', 'Experience Years', 'Height (cm)', 'Weight (kg)', 'Savings', 'Days of Vacation', 'Average Speed (kmph)'],
- ['John Doe', 30, 'New York', 75000.50, 5, 180, 75.5, 120000.75, 20, 45.5],
- ['Jane Smith', 25, 'Los Angeles', 65000.75, 3, 165, 60.2, 95000.20, 15, 40.0],
- # Add more data as needed
- ]
- # Write data to the CSV file
- with open(filename, 'w', newline='') as csvfile:
- csvwriter = csv.writer(csvfile)
- csvwriter.writerows(data)
- if __name__ == "__main__":
- # Set the filename for the example CSV file
- example_filename = 'example.csv'
- # Create the example CSV file in the current working directory
- create_example_csv(example_filename)
- print(f"Example CSV file '{example_filename}' created in the current working directory.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement