Skip to content
Snippets Groups Projects

Try several encodings to read old WEO releases

Closed Pierre Dittgen requested to merge flex_csv_read into master
2 unresolved threads
Edited by Christophe Benz

Merge request reports

Approval is optional

Closed by Christophe BenzChristophe Benz 4 years ago (Oct 19, 2020 9:13am UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
60 60 return slugify(lower_unit_label, separator="_", stopwords=["of"])
61 61
62 62
63 def dataframe_from_csv(csv_file: Path, encoding_list):
64 """Try several encodings to read csv content."""
65 for encoding in encoding_list:
66 try:
67 return pd.read_csv(csv_file, delimiter="\t", encoding=encoding)
68 except:
  • 60 60 return slugify(lower_unit_label, separator="_", stopwords=["of"])
    61 61
    62 62
    63 def dataframe_from_csv(csv_file: Path, encoding_list):
    64 """Try several encodings to read csv content."""
    65 for encoding in encoding_list:
    66 try:
    67 return pd.read_csv(csv_file, delimiter="\t", encoding=encoding)
    68 except:
    69 pass
    70 raise Exception(f"Can't find an encoding to read {csv_file!r}")
  • Pierre Dittgen added 1 commit

    added 1 commit

    • 737cde1b - Better catch and raise Exception

    Compare with previous version

  • Christophe Benz changed title from Try several encoding to read old WEO releases to Try several encodings to read old WEO releases

    changed title from Try several encoding to read old WEO releases to Try several encodings to read old WEO releases

  • Closing in favor of !2 (merged)

  • Please register or sign in to reply