I would like to be able to add the day, month and year to the end of the filename. I plan on running a version of this script every day so I would like it to create a new file each day. I would like the file to look like "beta6.8.2007.csv" Any idea on how to do this?

import csv
import datetime
now = datetime.datetime.now()
day=int(now.day)
month=int(now.month)
year=int(now.year)

writer = csv.writer(open(("beta.csv"), "ab"))
  writer.writerow(row)

Recommended Answers

All 2 Replies

writer = csv.writer(open(("beta_%i.%i.%i.csv" % (now.day, now.month, now.year)), "ab")

Thank you for the quick response

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.