Hi friends,
:)
im a python newbie.
I am trying to extract lines from my input file. Output the result to individual files
the first file results were ok. it extracted the sentences with pear in it
but the next file results - it simply out put the original phrase file.
I am not very experienced and have tried multiple things regarding outputting the results
if some one can take a look at this i would be grateful
I hope i worded my first post correctly
thank you for your time
:)
im a python newbie.
I am trying to extract lines from my input file. Output the result to individual files
import os Words=['Pear','Cherry'] input_file="c:/Users/Dan/Desktop/Python/Phrases.txt" with open(input_file,'r') as inFile: text = inFile.read() sentences = text.split(".") for s in Words: with open("%s.txt" % s, "w") as f: for sentence in sentences: if (any(map(lambda word: word in sentence, Words))): f.write(sentence + '\n')
the first file results were ok. it extracted the sentences with pear in it
but the next file results - it simply out put the original phrase file.
I am not very experienced and have tried multiple things regarding outputting the results
if some one can take a look at this i would be grateful
I hope i worded my first post correctly
thank you for your time