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
JdaDelete
1 hour agoHollow Knight: Silksong - Steel Soul [Permadeath]
34 watching -
LIVE
FLRG
1 hour agoFLRG LIVE ROAD TO 2015 FOLLOWERS
4 watching -
1:05:10
The Nick DiPaolo Show Channel
4 hours agoKirk Assassination Theories Abound! | The Nick Di Paolo Show #1795
27.4K27 -
LIVE
Focus_Up
46 minutes agoGrinding resurgence ranked!! Playing with Subscribers!! Lets have some fun!!!
232 watching -
LIVE
Chrono
59 minutes agoSplat-Tasks 2 - Splatoon but with more Rules
240 watching -
41:09
Katie Miller Pod
17 hours ago $0.95 earnedEpisode 8 - Adena Friedman | The Katie Miller Podcast
16.8K -
GritsGG
6 hours agoDuos! Most Wins in WORLD! 3680+!
10.6K -
1:45:18
Kim Iversen
3 hours agoSnake Eyes to Charlie Kirk: Is Life Copying this Hollywood Script?
34K40 -
1:05:24
TheCrucible
3 hours agoThe Extravaganza! EP: 44 (9/29/25)
102K9 -
1:39:07
Redacted News
4 hours agoThe FBI's Charlie Kirk assassination story has fully collapsed as new details emerge | Redacted News
156K157