find the creation date of a csv file in python

You can find the creation date of a csv file in Python by using the os and datetime modules. Here's an example code:

main.py
import os
import datetime

filename = 'mydata.csv'  # Replace with your csv filename

# Get the creation time of the file in seconds since Epoch
creation_time = os.path.getctime(filename)

# Convert the creation time into a readable format
creation_date = datetime.datetime.fromtimestamp(creation_time)

# Print the creation date of the file
print("The csv file {} was created on {}".format(filename, creation_date))
417 chars
14 lines

This code gets the creation time of the csv file using the os.path.getctime() function, which returns the time of the file's creation in seconds since Epoch. Then it converts the creation time into a human-readable format using the datetime.datetime.fromtimestamp() function. Finally, the code prints out the creation date of the file.

related categories

gistlibby LogSnag