I need to write a code that imports a list of files then goes through each file and rewrites only half the file. Cutting off the file at a key word. If I can make my code print the half I need I can make it write new files with the needed information. I am able to read the lines of each file and index the word I am using as the spliting spot but I am unsure where to go from here. I need to figure out how to print everything after the word "END"
dwhite12
0
Newbie Poster
Recommended Answers
Jump to PostUse
keep, _ = f.read().split('END',1)
Jump to PostInstead of the for loop.
Jump to PostTake out readlines.
Jump to Post_, keep instead of keep, _
All 14 Replies
dwhite12
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
svfox2000
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
TrustyTony
888
pyMod
Team Colleague
Featured Poster
dwhite12
0
Newbie Poster
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.