I'm new to python What I want is to be able to print content of a file I have like this..
Mashed Potatoes , topped with this and that ...................... 9.99$
similarly
Product_name , description ......................... price
when I match it with a file containing only Product_names
Mashed Potatoes
Past
Caesar Salad
etc. etc.
The content of the first file are not in a uniform order so that's why I'm trying it with search ,match and print approach
I hope you understand my problem
This is what I have tried
import re
content_file = open('/Users/ashishyadav/Downloads/pdfminer-20110515/samples/te.txt',"r")
product_list = open('/Users/ashishyadav/Desktop/AQ/te.txt',"r")
output = open("output.txt" , "w")
line = content_file.read().lower().strip()
for prod in product_list:
for match in re.finditer(prod.lower().strip(), line):
s=match.start()
e=match.end()
print >>output, match.group(),"\t",
print >>output, '%d:%d' % ( s, e),"\n",
what my code does is it matches the second product list file with the full content file but gives me just the index of the product_Names not the description and price ..
what I want is an index/span from Product_name to price..
like from mashed potatoes ---- 9.99$( mashed potatoes - [0:58]),,m just getting [0:14]
and also any way to print the description and price using the same approach
Thanks in advance
Let me know if you need this in python.