You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.0 KiB

  1. import csv
  2. def correction_csv(nomdufichier):
  3. csv_corrige = ''
  4. with open(f'{nomdufichier}.csv', newline='', encoding='utf-8') as csvfile:
  5. appariement_0 = csv.reader(csvfile, delimiter=' ')
  6. for row in appariement_0:
  7. ligne_brute =' '.join(str(elem) for elem in row)
  8. ligne_brute = ligne_brute.replace("ê", "ê")
  9. ligne_brute = ligne_brute.replace("é", "é")
  10. ligne_brute = ligne_brute.replace('Ã\xa0', "à")
  11. ligne_brute = ligne_brute.replace('è', "è")
  12. ligne_brute = ligne_brute.replace('ô', "ô")
  13. ligne_brute = ligne_brute.replace('û', "û")
  14. ligne_brute = ligne_brute.replace('î', "î")
  15. ligne_brute = ligne_brute.replace('â', "â")
  16. ligne_brute = ligne_brute.replace('É', 'É')
  17. ligne_brute = ligne_brute.replace('ç', 'ç')
  18. csv_corrige = csv_corrige + ligne_brute + '\n'
  19. print(ligne_brute)
  20. fichier_txt=open(f"{nomdufichier}_correct_bis.csv","w", encoding='utf-8')
  21. fichier_txt.write(csv_corrige)
  22. fichier_txt.close()
  23. # correction_csv('emissions')
  24. # correction_csv('etablissements')
  25. #correction_csv('Prelevements')
  26. #correction_csv('Prod_dechets_dangereux')
  27. # correction_csv('Prod_dechets_non_dangereux')
  28. # correction_csv('Trait_dechets_dangereux')
  29. # correction_csv('Trait_dechets_non_dangereux')
  30. # correction_csv('tr_nap')
  31. # correction_csv('tr_naf')
  32. correction_csv('tr_code_effectif')
  33. # correction_csv('te_siren_adresse')
  34. # correction_csv('te_siren_admin')
  35. # def remplacement_carac(nom_str):
  36. # nom_str = nom_str.replace("ê", "ê")
  37. # nom_str = nom_str.replace("é", "é")
  38. # nom_str = nom_str.replace('Ã\xa0', "à")
  39. # nom_str = nom_str.replace('è', "è")
  40. # nom_str = nom_str.replace('ô', "ô")
  41. # nom_str = nom_str.replace('û', "û")
  42. # nom_str = nom_str.replace('î', "î")
  43. # nom_str = nom_str.replace('â', "â")
  44. # nom_str = nom_str.replace('É', 'É')