Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf8 -*-
- import sys, csv, codecs, webbrowser
- #Turbolister CSV File
- tl_csv_file = "/home/Turbolister_CSV.csv"
- #Define CSV Reader
- tl_csv_reader = csv.DictReader(codecs.open(tl_csv_file, "rb"),delimiter=';')
- #Choose search type
- def def_search_type():
- print "\nsearch script for turbolister csv file\n"
- search_type = raw_input("search for code[c], title[t] or desription[d]?:\n")
- return search_type
- def code_search():
- new_search = ""
- while new_search != "n":
- tl_csv_reader = csv.DictReader(codecs.open(tl_csv_file, "rb"),delimiter=';')
- input_code = raw_input("please enter product to search for: ")
- results=[]
- for line in tl_csv_reader:
- if line["Custom Label"].count(input_code):
- results.append((line["Custom Label"], line["Title"], line["Description"]))
- print line["Custom Label"]
- len_results = len(results)
- print "%s results, open in browser?" % len_results
- opentrue = raw_input("y/n\n")
- if opentrue == "y":
- results_file = "/tmp/result_file1.html"
- f = open(results_file, 'w')
- for product in results:
- print len(product)
- f.write(product[2])
- f.close()
- webbrowser.open(results_file,new=2)
- if opentrue == "n":
- new_search = raw_input("new search? (y/n):\n")
- while True:
- search_type = def_search_type()
- if search_type == "c":
- while True:
- code_search()
- elif search_type == "t":
- print "not implemented yet"
- elif search_type == "d":
- print "not implemented yet"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement