Aug-09-2020, 05:29 AM
Hi,
I’m trying to ignore all lines that have word CMV in .csv file, problem is some of the lines have small case “cmv”. Basically I’m splitting my file on coma and then if the string[1] has a “CMV” or “cmv” I need to ignore.
Here is the code, for some reason I cannot make the code to be case insensitive.
Thank you.
I’m trying to ignore all lines that have word CMV in .csv file, problem is some of the lines have small case “cmv”. Basically I’m splitting my file on coma and then if the string[1] has a “CMV” or “cmv” I need to ignore.
Here is the code, for some reason I cannot make the code to be case insensitive.
Thank you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import os f_ticket = 'C:/Tickets/' f_clean = open ( 'C:/Tc/T_Clean.csv' , 'w' ) mt_cap = 'CMV' mt_sma = 'cmv' for root,dirs,files in os.walk(f_ticket): for ft in files: tk_p = f_ticket + ft print ( "CSV Files-- " ,tk_p) with open (tk_p, 'r' ) as f_csv : for ln_f_csv in f_csv : mysplit = ln_f_csv.split ( "," ) if mt_cap and mt_sma in mysplit[ 1 ] : print ( "MATCHED -->> " ,mysplit[ 1 ] ) else : f_clean.write(ln_f_csv) f_clean.close() |