I have multiple .txt files (O1test, O2test, O3test, O4test)
text of 01test(hello,my,friend,sorry,newbie)
text of 02test(hello,my,friend,sorry,newbie)
text of 03test(hello,my,friend,sorry,noob)
text of 04test(hello,my,friend,sorry,amatuer)
Output txt file may looks like this
Newbie
01test
02test
Noob
O3test
Amatuer
O4test
As you can see I need to write a name of file and xxth line of text and again name of file and xxth line of text but if xxth line is the same as previous go next.
I've tried something but now I'm stuck.
import os
for root, dirs, files in os.walk("C:\\Users\\42077\\Desktop\\test\\"):
for file in files:
if file.endswith(".txt"):
with open("C:\\Users\\42077\\Desktop\\test\\!output.txt", "a") as f: as f
f.write(os.path.join( file)+"\n")