Python Forum
If this and that "case insensitive"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If this and that "case insensitive"
#1
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.
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()
Reply


Messages In This Thread
If this and that "case insensitive" - by tester_V - Aug-09-2020, 05:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Switch case or match case? Frankduc 9 7,567 Jan-20-2022, 01:56 PM
Last Post: Frankduc
  regex and case insensitive Leon79 8 4,827 Jul-20-2020, 11:04 AM
Last Post: Leon79

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020