Skip to content

Commit

Permalink
Force utf-8 encoding when reading CSV files (thanks, Windows!)
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Jan 2, 2025
1 parent 2c91aca commit 9e33be5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyinaturalist_convert/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def is_csv_export(file_path: PathOrStr) -> bool:
"""Check if a file is a CSV export from the iNaturalist export tool (to distinguish from
converted API results)
"""
with open(file_path) as f:
with open(file_path, encoding='utf-8') as f:
reader = DictReader(f)
fields = next(reader).keys()
# Just check for a field name that's only in the export and not in API results
Expand Down
2 changes: 1 addition & 1 deletion pyinaturalist_convert/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _next_row(self) -> List:


def get_fields(csv_path: PathOrStr, delimiter: str = ',') -> List[str]:
with open(csv_path) as f:
with open(csv_path, encoding='utf-8') as f:
reader = csv_reader(f, delimiter=delimiter)
return next(reader)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyinaturalist-convert"
version = "0.6.5"
version = "0.6.6"
description = "Data conversion tools for iNaturalist observations and taxonomy"
authors = ["Jordan Cook"]
license = "MIT"
Expand Down

0 comments on commit 9e33be5

Please sign in to comment.