Use Python to search and pull data from Excel -
import csv subject = ['emergency*', 'new ticket*', 'problem with*'] from_to = ['chris*', 'timothy*', 'daniel*', 'david*', 'jason*'] = open('d:\testfile.csv', 'w') new python. so, here's i'd do.
1) open excel csv file
2) search specific keywords in list
3) if keywords found, pull data in d,e,f columns only. (since keywords be)
4) write data new file
example. search testfile.csv of keywords in from_to list. if these keywords appear in d or e columns of excel , if corresponding column f not equal subject list, write new file has columns of d,e,f , associated lines, many there are, it
also, put stars next names/items in list denote wildcard, eg if from_to contains chris.gmail.com or daniel@yahoo.
this solution has list of keywords, input file read line line, tokenize each line list of strings, iterate keyword list check if of them in tokenized line. if keyword found writes line output file.
keywrds = ["word1", "word2", "etc"] open ("myfile.csv") fin: open ("outfile.txt") fout: line in fin: line_tokens = line.split(",") word in keywrds: if word in line_tokens: fout.write(line_tokens[3:6].join(" ") + "\n")
Comments
Post a Comment