Premium Only Content

Working with Dates and Times |Section 6|Celestial Warrior
Here is a tricky exercise.
1.Please download thethree text files attached in this lecture and put them in a folder. The first text file contains the textContent1.The second contains Content2and the third Content3.
2. You should create a Python script that generates a new text file which should contain the content of all three text files. So the generated file should have this content:
Content1
Content2
Content3
In other words, your Pythonscript should merge the three text files.
3. Also, the name of the output file should be the current timestamp. Example:2017-11-01-13-57-39-170965.txt
You have some tips in the next lecture and the solution in the lecture afterthat.
1. Consider using the glob2 third-party library to generate a list of filenames to iterate through.
2. Use a "with" statement to create a new text file and then iterate through the file list inside that "with"statement and open andread existing file contentsin each iterationand write them to new text file.
import glob2
import datetime
filenames=glob2.glob("*.txt")
with open(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")+".txt", 'w') as file:
for filename in filenames:
with open(filename,"r") as f:
file.write(f.read()+"\n")
-
LIVE
The Jimmy Dore Show
2 hours agoTrump Administration Sends Accused Pedo BACK TO ISRAEL! Ukrainians Now OVERWHELMINGLY Oppose War!
9,630 watching -
6:44:51
Dr Disrespect
8 hours ago🔴LIVE - DR DISRESPECT - IMPOSSIBLE 5 CHICKEN DINNER CHALLENGE - FEAT. VISS
91.2K15 -
LIVE
GloryJean
55 minutes agoDominating The Sniper Role 🖱️ 6.7 K/D | Duos w/ Spartakus
15 watching -
LIVE
BigTallRedneck
54 minutes agoBRRRAP PACK VS ANYBODY!!
49 watching -
1:09:21
TheCrucible
3 hours agoThe Extravaganza! Ep. 24 (8/20/25)
56K7 -
1:18:42
Kim Iversen
3 hours agoUFO Base Area 51 Catches Fire… Is It a Massive Cover-Up?!
29.5K49 -
1:51:18
Redacted News
4 hours ago"There will be consequences!!!" Trump issues big threat to Putin ahead of peace summit | Redacted
97.8K83 -
53:14
Candace Show Podcast
4 hours agoThe MOST MORAL Blackmail In The World | Candace EP 231
51.4K134 -
1:11:28
vivafrei
5 hours agoMatt Taibbi Getting "Westfalled"? Kathy Hochul Fighting for Illegals! Mamdani Minority Report & MORE
98.2K57 -
2:03:39
Pop Culture Crisis
5 hours agoWTF Happened to Miley Cyrus? HARRY POTTER Set Images, Sydney Sweeney Hater EXPOSED | Ep. 901
42.5K21