Answer the question
In order to leave comments, you need to log in
How to get only full matches with query from csv?
Good afternoon!
Here is the code:
import csv
with open('test.csv', mode='r') as f:
reader = csv.reader(f)
for num, row in enumerate(reader):
day = str(200)
if day in row[0]:
a = row[0].count("P")
print(row[0], " --- ", a)
200;O;O;P;P;O;O;P;P;O;O;O;O;P;P;O;O;P;P;O;O;O --- 8
200;P;P;O;O;P;P;O;O;P;P;P;P;O;O;P;P;O;O;P;P;P --- 13
2200;O;O;P;P;O;O;P;P;O;O;O;O;P;P;O;O;P;P;O;O;O --- 8
11200;O;O;P;P;O;O;P;P;O;O;O;O;P;P;O;O;P;P;O;O;O --- 8
57200;P;P;O;O;P;P;O;O;P;P;P;P;P;O;P;P;O;O;P;P;P --- 14
7720077;O;O;P;P;O;O;P;P;O;O;O;O;P;P;O;O;P;P;O;O;O --- 8
12005;P;P;O;O;P;P;O;O;P;P;P;P;O;O;P;P;O;O;P;P;P --- 13
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question