Python: How to read between two words from a text file in python2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Difference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?How to get the current time in PythonHow can I make a time delay in Python?How to concatenate two lists in Python?How do I list all files of a directory?How to read a file line-by-line into a list?Why is reading lines from stdin much slower in C++ than Python?
Fastest way to pop N items from a large dict
A single argument pattern definition applies to multiple-argument patterns?
Non-trivial topology where only open sets are closed
A diagram about partial derivatives of f(x,y)
PTIJ: Who should I vote for? (21st Knesset Edition)
Is it insecure to send a password in a `curl` command?
About the actual radiative impact of greenhouse gas emission over time
Does multi-classing into Fighter give you heavy armor proficiency?
Examples of transfinite towers
Knife as defense against stray dogs
Is there a place to find the pricing for things not mentioned in the PHB? (non-magical)
Does .bashrc contain syntax errors?
Explaining pyrokinesis powers
What is the meaning of まっちろけ?
If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?
The meaning of 振り in 無茶振り
Employee lack of ownership
How can we have a quark condensate without a quark potential?
Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible
Different outputs for `w`, `who`, `whoami` and `id`
While on vacation my taxi took a longer route, possibly to scam me out of money. How can I deal with this?
Why is there is so much iron?
How could an airship be repaired midflight?
How to explain that I do not want to visit a country due to personal safety concern?
Python: How to read between two words from a text file in python
2019 Community Moderator ElectionHow to merge two dictionaries in a single expression?How do I check whether a file exists without exceptions?Difference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?How to get the current time in PythonHow can I make a time delay in Python?How to concatenate two lists in Python?How do I list all files of a directory?How to read a file line-by-line into a list?Why is reading lines from stdin much slower in C++ than Python?
I have a txt file which is basically a question paper, I wanted to read that file and execute some operations between two words.
Let's say there are 3 parts, PART A, PART B, PART C, and I wanted to do some operations like check all the question numbers whether is it present between PART A and PART B.
Check this link of the question paper
I wanted to check whether all the 12 questions are present in part A section
To summarise I wanted to read only between two words within the txt file
This is the entire code.
im comparing between two question papers
Note: its raw code not completed
# Ask the user to enter the names of files to compare
fname1 = input("Enter the Blue print name: ")
fname2 = input("Enter the Source name: ")
# Open file for reading in text mode (default mode)
f1 = open(fname1)
f2 = open(fname2)
# Print confirmation
print("-----------------------------------")
print("Comparing files ", " BP " + fname1, " SRC " +fname2, sep='n')
print("-----------------------------------")
# Read the first line from the files
f1_line = f1.readline()
f2_line = f2.readline()
# Initialize counter for line number
line_no = 1
NoError=True
# Loop if either file1 or file2 has not reached EOF
while f1_line != '' or f2_line != '':
# Strip the leading whitespaces
f1_line = f1_line.rstrip()
f2_line = f2_line.rstrip()
# Compare the lines from both file
if f1_line != f2_line:
# If a line does not exist on file2 then mark the output with + sign
if f2_line == '' and f1_line != '':
NoError=False
print("Additional line found in BP", "Line-%d" % line_no, f1_line)
# otherwise output the line on file1 and mark it with > sign
elif f1_line != '':
print("Please check BP", "Line-%d" % line_no, f1_line)
NoError=False
# If a line does not exist on file1 then mark the output with + sign
if f1_line == '' and f2_line != '':
print("Additional line found in SRC ", "Line-%d" % line_no, f2_line)
NoError=False
# otherwise output the line on file2 and mark it with < sign
elif f2_line != '':
print("Please check SRC", "Line-%d" % line_no, f2_line)
NoError=False
#Read the next line from the file
f1_line = f1.readline()
f2_line = f2.readline()
#Increment line counter
line_no += 1
if NoError:
print("Both files are same")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for partsn")
print("-----------------------------------")
#Checking for parts
#Put the parts in as p1 for part A, p2 for part b etc.....
p1 = "Part A"
p2 = "Part B"
#Checking parts condition in Blue print file
if p1 in open(fname1).read():
print("Part A found in BP")
else:
print("Part A not found BP")
if p2 in open(fname1).read():
print("Part B found in BP")
else:
print("Part B not found BP")
#Checking parts condition in Source file
if p1 in open(fname2).read():
print("Part A found in Src")
else:
print("Part A not found Src")
if p2 in open(fname2).read():
print("Part B found in Src")
else:
print("Part B not found Src")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for questionsn")
print("---------BLUE PRINT---------")
print("PART A")
parta = [".".format(i+1) for i in range(12)]
found_alla = True
with open(fname1) as file:
text = file.read()
for word in parta:
if word not in text:
found_alla= False
print(" not foundn".format(word))
if found_alla:
print("all questions found in Part A of Blue printn")
print("PART B")
partb = ["".format(i+1) for i in range(5)]
found_allb = True
with open(fname1) as file:
text = file.read()
for word in partb:
if word not in text:
found_allb= False
print(" not foundn".format(word))
if found_allb:
print("all questions found in Part B of Blue print")
print("---------SOURCE---------")
print("PART A")
partas = [".".format(i+1) for i in range(12)]
found_allaS = True
with open(fname2) as file:
text = file.read()
for word in partas:
if word not in text:
found_allaS= False
print(" not foundn".format(word))
if found_allaS:
print("all questions found in Part A of SOURCEn")
print("PART B")
partbS = [".".format(i+1) for i in range(5)]
found_allBS = True
with open(fname2) as file:
text = file.read()
for word in partbS:
if word not in text:
found_allbS= False
print(" not foundn".format(word))
if found_allbS:
print("all questions found in Part B of SOURCE")
f1.close()
f2.close()
input("Press Enter to close")
python python-3.x python-import readline
add a comment |
I have a txt file which is basically a question paper, I wanted to read that file and execute some operations between two words.
Let's say there are 3 parts, PART A, PART B, PART C, and I wanted to do some operations like check all the question numbers whether is it present between PART A and PART B.
Check this link of the question paper
I wanted to check whether all the 12 questions are present in part A section
To summarise I wanted to read only between two words within the txt file
This is the entire code.
im comparing between two question papers
Note: its raw code not completed
# Ask the user to enter the names of files to compare
fname1 = input("Enter the Blue print name: ")
fname2 = input("Enter the Source name: ")
# Open file for reading in text mode (default mode)
f1 = open(fname1)
f2 = open(fname2)
# Print confirmation
print("-----------------------------------")
print("Comparing files ", " BP " + fname1, " SRC " +fname2, sep='n')
print("-----------------------------------")
# Read the first line from the files
f1_line = f1.readline()
f2_line = f2.readline()
# Initialize counter for line number
line_no = 1
NoError=True
# Loop if either file1 or file2 has not reached EOF
while f1_line != '' or f2_line != '':
# Strip the leading whitespaces
f1_line = f1_line.rstrip()
f2_line = f2_line.rstrip()
# Compare the lines from both file
if f1_line != f2_line:
# If a line does not exist on file2 then mark the output with + sign
if f2_line == '' and f1_line != '':
NoError=False
print("Additional line found in BP", "Line-%d" % line_no, f1_line)
# otherwise output the line on file1 and mark it with > sign
elif f1_line != '':
print("Please check BP", "Line-%d" % line_no, f1_line)
NoError=False
# If a line does not exist on file1 then mark the output with + sign
if f1_line == '' and f2_line != '':
print("Additional line found in SRC ", "Line-%d" % line_no, f2_line)
NoError=False
# otherwise output the line on file2 and mark it with < sign
elif f2_line != '':
print("Please check SRC", "Line-%d" % line_no, f2_line)
NoError=False
#Read the next line from the file
f1_line = f1.readline()
f2_line = f2.readline()
#Increment line counter
line_no += 1
if NoError:
print("Both files are same")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for partsn")
print("-----------------------------------")
#Checking for parts
#Put the parts in as p1 for part A, p2 for part b etc.....
p1 = "Part A"
p2 = "Part B"
#Checking parts condition in Blue print file
if p1 in open(fname1).read():
print("Part A found in BP")
else:
print("Part A not found BP")
if p2 in open(fname1).read():
print("Part B found in BP")
else:
print("Part B not found BP")
#Checking parts condition in Source file
if p1 in open(fname2).read():
print("Part A found in Src")
else:
print("Part A not found Src")
if p2 in open(fname2).read():
print("Part B found in Src")
else:
print("Part B not found Src")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for questionsn")
print("---------BLUE PRINT---------")
print("PART A")
parta = [".".format(i+1) for i in range(12)]
found_alla = True
with open(fname1) as file:
text = file.read()
for word in parta:
if word not in text:
found_alla= False
print(" not foundn".format(word))
if found_alla:
print("all questions found in Part A of Blue printn")
print("PART B")
partb = ["".format(i+1) for i in range(5)]
found_allb = True
with open(fname1) as file:
text = file.read()
for word in partb:
if word not in text:
found_allb= False
print(" not foundn".format(word))
if found_allb:
print("all questions found in Part B of Blue print")
print("---------SOURCE---------")
print("PART A")
partas = [".".format(i+1) for i in range(12)]
found_allaS = True
with open(fname2) as file:
text = file.read()
for word in partas:
if word not in text:
found_allaS= False
print(" not foundn".format(word))
if found_allaS:
print("all questions found in Part A of SOURCEn")
print("PART B")
partbS = [".".format(i+1) for i in range(5)]
found_allBS = True
with open(fname2) as file:
text = file.read()
for word in partbS:
if word not in text:
found_allbS= False
print(" not foundn".format(word))
if found_allbS:
print("all questions found in Part B of SOURCE")
f1.close()
f2.close()
input("Press Enter to close")
python python-3.x python-import readline
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07
add a comment |
I have a txt file which is basically a question paper, I wanted to read that file and execute some operations between two words.
Let's say there are 3 parts, PART A, PART B, PART C, and I wanted to do some operations like check all the question numbers whether is it present between PART A and PART B.
Check this link of the question paper
I wanted to check whether all the 12 questions are present in part A section
To summarise I wanted to read only between two words within the txt file
This is the entire code.
im comparing between two question papers
Note: its raw code not completed
# Ask the user to enter the names of files to compare
fname1 = input("Enter the Blue print name: ")
fname2 = input("Enter the Source name: ")
# Open file for reading in text mode (default mode)
f1 = open(fname1)
f2 = open(fname2)
# Print confirmation
print("-----------------------------------")
print("Comparing files ", " BP " + fname1, " SRC " +fname2, sep='n')
print("-----------------------------------")
# Read the first line from the files
f1_line = f1.readline()
f2_line = f2.readline()
# Initialize counter for line number
line_no = 1
NoError=True
# Loop if either file1 or file2 has not reached EOF
while f1_line != '' or f2_line != '':
# Strip the leading whitespaces
f1_line = f1_line.rstrip()
f2_line = f2_line.rstrip()
# Compare the lines from both file
if f1_line != f2_line:
# If a line does not exist on file2 then mark the output with + sign
if f2_line == '' and f1_line != '':
NoError=False
print("Additional line found in BP", "Line-%d" % line_no, f1_line)
# otherwise output the line on file1 and mark it with > sign
elif f1_line != '':
print("Please check BP", "Line-%d" % line_no, f1_line)
NoError=False
# If a line does not exist on file1 then mark the output with + sign
if f1_line == '' and f2_line != '':
print("Additional line found in SRC ", "Line-%d" % line_no, f2_line)
NoError=False
# otherwise output the line on file2 and mark it with < sign
elif f2_line != '':
print("Please check SRC", "Line-%d" % line_no, f2_line)
NoError=False
#Read the next line from the file
f1_line = f1.readline()
f2_line = f2.readline()
#Increment line counter
line_no += 1
if NoError:
print("Both files are same")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for partsn")
print("-----------------------------------")
#Checking for parts
#Put the parts in as p1 for part A, p2 for part b etc.....
p1 = "Part A"
p2 = "Part B"
#Checking parts condition in Blue print file
if p1 in open(fname1).read():
print("Part A found in BP")
else:
print("Part A not found BP")
if p2 in open(fname1).read():
print("Part B found in BP")
else:
print("Part B not found BP")
#Checking parts condition in Source file
if p1 in open(fname2).read():
print("Part A found in Src")
else:
print("Part A not found Src")
if p2 in open(fname2).read():
print("Part B found in Src")
else:
print("Part B not found Src")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for questionsn")
print("---------BLUE PRINT---------")
print("PART A")
parta = [".".format(i+1) for i in range(12)]
found_alla = True
with open(fname1) as file:
text = file.read()
for word in parta:
if word not in text:
found_alla= False
print(" not foundn".format(word))
if found_alla:
print("all questions found in Part A of Blue printn")
print("PART B")
partb = ["".format(i+1) for i in range(5)]
found_allb = True
with open(fname1) as file:
text = file.read()
for word in partb:
if word not in text:
found_allb= False
print(" not foundn".format(word))
if found_allb:
print("all questions found in Part B of Blue print")
print("---------SOURCE---------")
print("PART A")
partas = [".".format(i+1) for i in range(12)]
found_allaS = True
with open(fname2) as file:
text = file.read()
for word in partas:
if word not in text:
found_allaS= False
print(" not foundn".format(word))
if found_allaS:
print("all questions found in Part A of SOURCEn")
print("PART B")
partbS = [".".format(i+1) for i in range(5)]
found_allBS = True
with open(fname2) as file:
text = file.read()
for word in partbS:
if word not in text:
found_allbS= False
print(" not foundn".format(word))
if found_allbS:
print("all questions found in Part B of SOURCE")
f1.close()
f2.close()
input("Press Enter to close")
python python-3.x python-import readline
I have a txt file which is basically a question paper, I wanted to read that file and execute some operations between two words.
Let's say there are 3 parts, PART A, PART B, PART C, and I wanted to do some operations like check all the question numbers whether is it present between PART A and PART B.
Check this link of the question paper
I wanted to check whether all the 12 questions are present in part A section
To summarise I wanted to read only between two words within the txt file
This is the entire code.
im comparing between two question papers
Note: its raw code not completed
# Ask the user to enter the names of files to compare
fname1 = input("Enter the Blue print name: ")
fname2 = input("Enter the Source name: ")
# Open file for reading in text mode (default mode)
f1 = open(fname1)
f2 = open(fname2)
# Print confirmation
print("-----------------------------------")
print("Comparing files ", " BP " + fname1, " SRC " +fname2, sep='n')
print("-----------------------------------")
# Read the first line from the files
f1_line = f1.readline()
f2_line = f2.readline()
# Initialize counter for line number
line_no = 1
NoError=True
# Loop if either file1 or file2 has not reached EOF
while f1_line != '' or f2_line != '':
# Strip the leading whitespaces
f1_line = f1_line.rstrip()
f2_line = f2_line.rstrip()
# Compare the lines from both file
if f1_line != f2_line:
# If a line does not exist on file2 then mark the output with + sign
if f2_line == '' and f1_line != '':
NoError=False
print("Additional line found in BP", "Line-%d" % line_no, f1_line)
# otherwise output the line on file1 and mark it with > sign
elif f1_line != '':
print("Please check BP", "Line-%d" % line_no, f1_line)
NoError=False
# If a line does not exist on file1 then mark the output with + sign
if f1_line == '' and f2_line != '':
print("Additional line found in SRC ", "Line-%d" % line_no, f2_line)
NoError=False
# otherwise output the line on file2 and mark it with < sign
elif f2_line != '':
print("Please check SRC", "Line-%d" % line_no, f2_line)
NoError=False
#Read the next line from the file
f1_line = f1.readline()
f2_line = f2.readline()
#Increment line counter
line_no += 1
if NoError:
print("Both files are same")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for partsn")
print("-----------------------------------")
#Checking for parts
#Put the parts in as p1 for part A, p2 for part b etc.....
p1 = "Part A"
p2 = "Part B"
#Checking parts condition in Blue print file
if p1 in open(fname1).read():
print("Part A found in BP")
else:
print("Part A not found BP")
if p2 in open(fname1).read():
print("Part B found in BP")
else:
print("Part B not found BP")
#Checking parts condition in Source file
if p1 in open(fname2).read():
print("Part A found in Src")
else:
print("Part A not found Src")
if p2 in open(fname2).read():
print("Part B found in Src")
else:
print("Part B not found Src")
print("---------------------------------------------------------------------n")
print("---------------------------------------------------------------------")
print("Checking for questionsn")
print("---------BLUE PRINT---------")
print("PART A")
parta = [".".format(i+1) for i in range(12)]
found_alla = True
with open(fname1) as file:
text = file.read()
for word in parta:
if word not in text:
found_alla= False
print(" not foundn".format(word))
if found_alla:
print("all questions found in Part A of Blue printn")
print("PART B")
partb = ["".format(i+1) for i in range(5)]
found_allb = True
with open(fname1) as file:
text = file.read()
for word in partb:
if word not in text:
found_allb= False
print(" not foundn".format(word))
if found_allb:
print("all questions found in Part B of Blue print")
print("---------SOURCE---------")
print("PART A")
partas = [".".format(i+1) for i in range(12)]
found_allaS = True
with open(fname2) as file:
text = file.read()
for word in partas:
if word not in text:
found_allaS= False
print(" not foundn".format(word))
if found_allaS:
print("all questions found in Part A of SOURCEn")
print("PART B")
partbS = [".".format(i+1) for i in range(5)]
found_allBS = True
with open(fname2) as file:
text = file.read()
for word in partbS:
if word not in text:
found_allbS= False
print(" not foundn".format(word))
if found_allbS:
print("all questions found in Part B of SOURCE")
f1.close()
f2.close()
input("Press Enter to close")
python python-3.x python-import readline
python python-3.x python-import readline
edited Mar 7 at 16:13
Appries
asked Mar 7 at 15:41
AppriesAppries
255
255
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07
add a comment |
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07
add a comment |
2 Answers
2
active
oldest
votes
I might be over simplifying this, but can you not just split at the headers to get what you need?
text = 'PART A: This is Part A, ham and eggs. PART B: This is part B, eggs and ham'
text.split('PART A:')[1].split('PART B:')[0].strip()
Resulting in:
'This is Part A, ham and eggs.'
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
add a comment |
You may first search using some if statements that on which line do the word come .
Then make a loop between the lines and operate as you wish.
For example if PART 1 comes on line 10 and PART 2 comes on line 18 then make a loop between lines 10 and 18 and operate as you wish.
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047654%2fpython-how-to-read-between-two-words-from-a-text-file-in-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I might be over simplifying this, but can you not just split at the headers to get what you need?
text = 'PART A: This is Part A, ham and eggs. PART B: This is part B, eggs and ham'
text.split('PART A:')[1].split('PART B:')[0].strip()
Resulting in:
'This is Part A, ham and eggs.'
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
add a comment |
I might be over simplifying this, but can you not just split at the headers to get what you need?
text = 'PART A: This is Part A, ham and eggs. PART B: This is part B, eggs and ham'
text.split('PART A:')[1].split('PART B:')[0].strip()
Resulting in:
'This is Part A, ham and eggs.'
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
add a comment |
I might be over simplifying this, but can you not just split at the headers to get what you need?
text = 'PART A: This is Part A, ham and eggs. PART B: This is part B, eggs and ham'
text.split('PART A:')[1].split('PART B:')[0].strip()
Resulting in:
'This is Part A, ham and eggs.'
I might be over simplifying this, but can you not just split at the headers to get what you need?
text = 'PART A: This is Part A, ham and eggs. PART B: This is part B, eggs and ham'
text.split('PART A:')[1].split('PART B:')[0].strip()
Resulting in:
'This is Part A, ham and eggs.'
answered Mar 7 at 15:52
RockHardRacoonRockHardRacoon
614110
614110
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
add a comment |
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
Thank you, it's working... What I did is text=file.read().split("PART A")[1].split("PART B")[0].strip()
– Appries
Mar 7 at 21:25
add a comment |
You may first search using some if statements that on which line do the word come .
Then make a loop between the lines and operate as you wish.
For example if PART 1 comes on line 10 and PART 2 comes on line 18 then make a loop between lines 10 and 18 and operate as you wish.
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
add a comment |
You may first search using some if statements that on which line do the word come .
Then make a loop between the lines and operate as you wish.
For example if PART 1 comes on line 10 and PART 2 comes on line 18 then make a loop between lines 10 and 18 and operate as you wish.
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
add a comment |
You may first search using some if statements that on which line do the word come .
Then make a loop between the lines and operate as you wish.
For example if PART 1 comes on line 10 and PART 2 comes on line 18 then make a loop between lines 10 and 18 and operate as you wish.
You may first search using some if statements that on which line do the word come .
Then make a loop between the lines and operate as you wish.
For example if PART 1 comes on line 10 and PART 2 comes on line 18 then make a loop between lines 10 and 18 and operate as you wish.
answered Mar 7 at 15:52
Gursewak DhindsaGursewak Dhindsa
351
351
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
add a comment |
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
can you read the description again and present the code!!!
– Appries
Mar 7 at 16:05
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55047654%2fpython-how-to-read-between-two-words-from-a-text-file-in-python%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Mathieu I dint think to putup the txt file since it was clear that i wanted to perform actions between two words, no issues ill upload em
– Appries
Mar 7 at 15:53
@Mathieu i have added the txt file
– Appries
Mar 7 at 16:07