Skip to content

Instantly share code, notes, and snippets.

@nsdevaraj
Created November 2, 2023 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nsdevaraj/b9aa7bf2169080152ce0ec936c81c594 to your computer and use it in GitHub Desktop.
Save nsdevaraj/b9aa7bf2169080152ce0ec936c81c594 to your computer and use it in GitHub Desktop.
import csv
# Open a CSV file for writing
with open('years_and_months.csv', 'w', newline='') as csvfile:
# Create a CSV writer
csvwriter = csv.writer(csvfile)
# Write the header
csvwriter.writerow(['Year', 'Month'])
# Generate data for the next 100 years
for year in range(2023, 2123):
for month in ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']:
csvwriter.writerow([year, month])
print("Data generation complete. Check 'years_and_months.csv'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment