I have the following block of code:
idatual=txt2['pvSystems'][x]['pvSystemId']
nomedocliente = txt2['pvSystems'][x]['name']
nomesclientes = pd.read_excel(file_loc, sheet_name="MONITORAMENTO", index_col=None, na_values=['NA'], usecols = "B")
y=0
print("name of the client: " + str(nomedocliente))
while y < len(nomesclientes):
print("name of the client on the sheets: " + nomesclientes.iloc[y][0])
if nomedocliente == nomesclientes.iloc[y][0]:
So, a few things worth noticing:
- "nomedocliente",the first element on the comparison, is taken from a response originated by a request.
- The idea is to compare "nomedocliente" to the values of a column from an Excel sheet, if the value is equal, we trigger an action.
- Both values are strings.
- The code works for the most values, but it doesn't work on very specific cases, like:
Case 1:
name of the client: Pice e Cia
name of the client on the sheets: Pice e Cia
Case 2:
name of the client: Iolanda Saraiva Irecê
name of the client on the sheets: Iolanda Saraiva Irecê
Problem cases don't have a pattern on them.
I've assured that those strings are equal, since they trigger if statements on other cases.
Any ideas ?
EDIT:
I've followed the solution that it was linked to this question and it did NOT help. I've changed the code to normalize the strings:
Older line:
if nomedocliente == nomesclientes.iloc[y][0]:
New Line:
if (unicodedata.normalize('NFC',str(nomedocliente)) == unicodedata.normalize('NFC',str(nomesclientes.iloc[y][0]))):
The problem was not solved.