Skip to content

Instantly share code, notes, and snippets.

@sblack4
Created September 4, 2020 15:00
Show Gist options
  • Save sblack4/3704eed89c2bd409b60078371810a5e3 to your computer and use it in GitHub Desktop.
Save sblack4/3704eed89c2bd409b60078371810a5e3 to your computer and use it in GitHub Desktop.
Write a list of dates to a file with python
import datetime
from datetime import timedelta, date
def test_backfill():
numdays = 720
base = datetime.datetime.today()
date_list = [base - datetime.timedelta(days=x) for x in range(numdays)]
with open('mahdates.csv', 'w') as f:
for date in date_list:
f.write(f'{date.strftime("%Y-%m-%d")}\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment