Skip to content

Commit

Permalink
Add try/except to wind rose loader
Browse files Browse the repository at this point in the history
  • Loading branch information
paulf81 committed Apr 5, 2024
1 parent 517092f commit 403e5b6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion floris/wind_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

import inspect
from abc import abstractmethod
from pathlib import Path

import matplotlib.cm as cm
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -680,7 +682,13 @@ def read_csv_long(file_path: str,
"""

# Read in the CSV file
df = pd.read_csv(file_path, sep=sep)
try:
df = pd.read_csv(file_path, sep=sep)
except FileNotFoundError:
# If the file cannot be found, then attempt the level above
base_fn = Path(inspect.stack()[-1].filename).resolve().parent
file_path = base_fn / file_path
df = pd.read_csv(file_path, sep=sep)

# Check that ti_col_or_value is a string or a float
if not isinstance(ti_col_or_value, (str, float)):
Expand Down

0 comments on commit 403e5b6

Please sign in to comment.