Index de l'article

Search by lines

Search some character getting column and row:

for row in df_ExportFeuil1.index:
    for col in df_ExportFeuil1.columns:
        cell_value = str(df_ExportFeuil1.at[row, col])
        if '\u2264' in cell_value:
            print(colored(f'Attention, signe inférieur ou égal à la ligne {row}, colonne {col} !', 'red'))

Or several very specific characters

###################################### GESTION/VÉRIFICATION DES CHAMPS TEXTE
print(colored('\nVérification des caractères "très" spéciaux...', 'blue'))
timeNow = time.process_time()
 
# LES CARACTÈRES WINDOWS QUI GÊNE L'EXPORT AUTOMATIQUE POUR UNE RAISON D'ENCODAGE TRÈS SPÉCIALE
for col in df_ExportFeuil1.columns:
    if col in ChampsTexte:
        for row in df_ExportFeuil1.index:
            index = row + 4
            cell_value = str(df_ExportFeuil1.at[row, col])
 
            # Saut de ligne \r
            if '\r' in cell_value:
                print(colored(f'Attention, saut de ligne (\\r) à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Saut de ligne \n
            elif '\n' in cell_value:
                print(colored(f'Attention, saut de ligne (\\n) à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Tabulation
            elif '\t' in cell_value:
                print(colored(f'Attention, tabulation à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Espace fine
            elif '\u2009' in cell_value:
                print(colored(f'Attention, espace fine à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Supérieur ou égal
            elif '\u2265' in cell_value:
                print(colored(f'Attention, signe supérieur ou égal à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Inférieur ou égal ou égal
            elif '\u2264' in cell_value:
                print(colored(f'Attention, signe inférieur ou égal à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Delta
            elif '\u0394' in cell_value:
                print(colored(f'Attention, signe delta à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Tiret demi-cadratin
            elif '\u2013' in cell_value:
                print(colored(f'Attention, tiret demi-cadratin à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Caractère invalide
            elif '\ufffd' in cell_value:
                print(colored(f'Attention, caractère invalide à la ligne {index} notamment, colonne {col} !', 'red'))
                sys.exit()
 
            # Point d'interrogation
            elif '?' in cell_value:
                print(colored(f'Attention, Point d\'interrogation à la ligne {index} notamment, colonne {col}.', 'yellow'))
                sys.exit()
 
            # Point d'exclamation
            elif '!' in cell_value:
                print(colored(f'Attention, Point d\'exclamation à la ligne {index} notamment, colonne {col}.', 'yellow'))
                sys.exit()
 
            # Apostrophe spéciale
            elif '’' in cell_value:
                print(colored(f'Attention, Apostrophe spéciale à la ligne {index} notamment, colonne {col}.', 'yellow'))
                sys.exit()
 
            # Tiret spécial
            elif '‐' in cell_value:
                print(colored(f'Attention, Tiret spécial à la ligne {index} notamment, colonne {col}.', 'yellow'))
                sys.exit()
 
            # Commence par "%"
            elif cell_value.lstrip().startswith('%'):
                print(colored(f'Attention, "%" en début de ligne {index} notamment, colonne {col}.', 'yellow'))
                sys.exit()
 
print(colored('Vérification des caractères "très" spéciaux terminée en %s secondes !' % round(time.process_time() - timeNow, 1), 'blue'))
timeNow = time.process_time()

 

Liens ou pièces jointes
Télécharger ce fichier (France-Departements-Deformation.zip)France-Departements-Deformation.zip[France-Departements-Deformation]335 Ko
Télécharger ce fichier (simple_countries.zip)simple_countries.zip[simple_countries]1880 Ko