excel - Finding all instances where a matchword is used in a csv file using python -
i have csv file has numerous columns
here image of excel file looks http://i.stack.imgur.com/ab6tp.png
i need through thousands of rows, in column labeled hit definition virus name "grapevine" in it. each word name "grapevine", need compile how many times mentioned, range of length (column labeled query length, [2]), , summation of reads(column total reads, [4]).
input: http://i.stack.imgur.com/ab6tp.png
output:
grapevine 1 6 234-234234 45634
grapevine 2 7 123-65432 12341
with open(argv[1], 'r') f: line in csv.reader(f): contig_name = line[0] contig_length = line[3] read_count = line[4] hit_def = line[6] try: pattern = r'.\[(.*?)\].' hit_sub = re.search(pattern, hit_def).group(1) print hit_sub except attributeerror: hit_sub = hit_def target.append([hit_sub])
this have far lost on how filter names
since you're lost on how filter names, try:
re.findall("grapevine",f)
Comments
Post a Comment