Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dayliopy/fit_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import pandas as pd
import statsmodels.api

from .lib import CSV_ENCODING
from .lib.config import AppConf


Expand Down Expand Up @@ -79,7 +80,7 @@ def fit_model_to_csv(csv_in_path: str):

:param csv_in_path: Path to cleaned CSV.
"""
df = pd.read_csv(csv_in_path)
df = pd.read_csv(csv_in_path, encoding=CSV_ENCODING)

encoded_df = prepare_data(df)

Expand Down
5 changes: 5 additions & 0 deletions dayliopy/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@


APP_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))

# Encoding added to avoid error on Windows
# https://github.com/MichaelCurrin/daylio-csv-parser/issues/25

CSV_ENCODING = "latin-1"
6 changes: 5 additions & 1 deletion dayliopy/mood_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import pandas as pd

from .lib import CSV_ENCODING
from .lib.config import AppConf


Expand Down Expand Up @@ -51,12 +52,15 @@ def make_report(csv_in_path: str) -> None:
"""
Make report from input CSV and show.


:param: csv_in_path: Path to cleaned CSV, as generated by clean_csv.py
application.

:return: None
"""
df = pd.read_csv(csv_in_path, usecols=["mood_label", "mood_score"])
df = pd.read_csv(
csv_in_path, usecols=["mood_label", "mood_score"], encoding=CSV_ENCODING
)

print_aggregate_stats(df, "mood_score")
print()
Expand Down