How to apply case Insensitive filter

how to filter cells with case sensitive in excel
case sensitive filter in excel
vba autofilter case sensitive
formulas are case sensitive
case sensitive pivot table
find uppercase words in excel
count cells equal to case sensitive
filter by case in excel

So I have CSV1:

Name, City, Country  
David, Los Angeles, US    
Peter, Chicago, US  
Mark, Chicago, US  
Brian, New York, US  
Paul, Los Angeles, US  
Andy, Boston, US  
Chris, Dallas, US  

And CSV2:

City, Name, Country  
PETER, Chicago, US  
Adam, Florida, US  
MARK, Chicago, US  
James, Austin, US  
BRIAN, New York, US  

I want to remove redundant names. It doesn't matter what the City and Country are, because I only have to write the names to the output csv file. So in this case, for BRIAN and brian it will remove the redundant data and take only one name (brian). At the same time, I want the data('Name') that is CSV1 but not in CSV2, to be printed to the output file as well. So, basically, it is a case insensitive filter. Something like this:


I have tried this code:

import csv

# load second file as lookup table
data2 = {}
data1 = {}
with open('CSV2.csv', 'r') as csvinput:
    reader = csv.reader(csvinput)
    for row in csvinput:
        data2[row[1]] = row

# now process first file against it
with open("CSV1.csv", 'r') as lookuplist:
    reader1 = csv.reader(lookuplist)
    for col in lookuplist:
        data1[col[0]] = col
        if col[0] not in data2:
        if col.lower()[0] == data2.lower()[1]:

This is the error that I am getting:

AttributeError: 'dict' object has no attribute 'lower'

I know there is something wrong with the list that I'm creating but I am not able to figure out if it is actually comparing lowercase of both the columns and printing the MATCHES as I want to verify it first.

It seems there is no need to import csv, as you can easily extract the information by splitting on the comma. Also, it might be preferable to add a check so that 'Name' is not considered like a valid name.

I don't know if that's a requirement, but say you needed to filter with a third file, I prefer to define a function we can call with parameters to build an unduped list right away.

def build_unduped_names(names_repository, file_name):
    with open(file_name) as csvinput:
        for row in csvinput:
            exploded_row = row.split(',')
            if exploded_row[0].lower() == 'name':
            names_repository[exploded_row[0].lower()] = True

file_names = [

unduped = {}
for file_name in file_names:
    build_unduped_names(unduped, file_name)


Perform a Case Sensitive Filter in Excel –, Excel Filters Are Not Case Sensitive To run a test on case we can use the EXACT function which allows us to compare two text values. STEP 1: Select your data and turn it into an Excel Table by pressing the shortcut Ctrl + T or by going to Insert > Table. STEP 2: Go to Data > Get & Transform > From Table (Excel 2016) or Power Query > Excel Data > From Table (Excel 2013 & 2010) Excel 2016: Excel 2013 & 2010: STEP 3: This will open up the Power Query Editor.

For one thing

if col.lower()[0] == data2.lower()[1]:

Should be:

if col[0].lower() == data2[1].lower():

That is what is causing the error

AttributeError: 'dict' object has no attribute 'lower'


To solve KeyError mentioned in comments:

for k, v in data2:
    if data2[k].lower() == col[0].lower():

You could also just compare by the variable v (representative of each value in the dict), but I used accessing the index by key for clarity on that functionality.

How to filter cells with case sensitive in Excel?, By default, Microsoft Excel's Filter command does not support case sensitive. For example, when you filter the uppercase of "TEXT TOOLS" in a column, it will  In one of this example app, I needed to filter the Business Partner’s CompanyName attribute (I’m using Netweaver Gateway Demo ES5). I’ve added a SearchField, I’ve attached the search event to my implementation on the Controller and tested it.

Try this:

csv1names = [(line.split()[0]).title() for line in csv1file]
csv2names = [(line.split()[0]).title() for line in csv2file]

filtered = [name if name not in csv2names for name in csv1names]

Then, you can simply write the contents of filtered to your file.

Case Insensitive Filtering Using Power Query, Did you know that you can do case insensitive filtering? I will show you how to do it step by step below! DOWNLOAD EXCEL WORKBOOK. STEP 1: Select your  String comparisons ARE case sensitive. Here's an example of where this can be a problem. The formula beneath attempts to apply conditional formatting to a data card. If the gender equals "male", the fill color of the card should be AliceBlue. As the screenshot shows, the fill color of the card is white.

import pandas as pd

df = pd.read_csv('location/filename.csv')
df['Name'] = df['Name'].apply(lambda x: x.capitalize())
print(df['Name'].unique()) #Now you will get all the unique names. 

Write these names to your required csv file

Filtering a case sensitive value, Hi Guys, Good day. I'm trying to find a solution on how to filter the exact value (​case sensitive) but I'm having a hard time to get a solution for. Configuring the database collation to ignore the case is the most productive solution. Is there no possibility to alter the database, e.g., due to lack of access rights or when a database is an external service, there is another recommendation, converting the database values to lower case before executing the database query.

Case sensitivity, In computers, case sensitivity defines whether uppercase and lowercase letters are treated as or city name may be interested in performing a case-sensitive operation to filter out irrelevant results. A text search operation could be case-​sensitive or case-insensitive, depending on the system, application, or context. How could you apply this case insensitive condition to attachment file extensions? I am having a problem where attachments that are ".PDF" as opposed to ".pdf" do not get included in the flow. The flow checks for emails in a specific folder in outlook for pdf attachments and saves them into a SharePoint folder.

Case-Insensitive filter, Hi, I am trying to create a Case-Insensitive filter on a column (Varchar). The column is ""Industry I pass these values as filter parameters in my query section​. Here, the user has to or lower case. Just use this as part of your filter. Basically  or lower case. Just use this as part of your filter. Basically, take whatever they typed on the dashboard and run a string.toUpperCase() on it before passing it to the filter. Then all you need to do is make sure that the filter uses your database's function for converting to upper case so that from a SQL standpoint it would read as:

#6904 (Dictsort filter should sort case insensitive) – Django, Dictsort filter currently sorts case sensitive and thus creates sometimes two groups depending on the case of the text being sorted. The filter should use. Join a community of over 2.6m developers to have your questions answered on Filtering - case insensitive? of UI for ASP.NET AJAX Grid. New here? Start with our free trials.

  • This one helped me with the logic that I needed and closely aligned with my script, Thank you!
  • data2 is a dictionary, it doesn't have the Key 1. You're assigning each index of data2 to row[1], you'll need to access it using each value assigned earlier from row[1].
  • For the last line: set(csv1names + csv2names)
  • @user3483203 Wouldn't work because names in csv2 which aren't in csv1 would also be included, which isn't what OP wants (look at Adam in the OP's example)
  • Then why is he even reading the second file if he takes no names from it?
  • @user3483203 (S)he's using the second file as a blacklist; any names which are in the second file aren't wanted.
  • It's the question that's unclear, it seems as though the second file as has no effect on the outcome :D
  • I am not using pandas. would be nice if you could provide a solution without using pandas here.