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
21 changes: 16 additions & 5 deletions pyepw/epw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7417,15 +7417,14 @@ def _create_datadict(cls, internal_name):
raise ValueError(
"No DataDictionary known for {}".format(internal_name))

def read(self, path):
"""Read EPW weather data from path.
def read_string_io(self, string_io):
"""Read EPW weather data from StringIO object.

Args:
path (str): path to read weather data from
string_io (StringIO): stringio to read weather data from

"""
with open(path, "r") as f:
for line in f:
for line in string_io:
line = line.strip()
match_obj_name = re.search(r"^([A-Z][A-Z/ \d]+),", line)
if match_obj_name is not None:
Expand All @@ -7440,3 +7439,15 @@ def read(self, path):
wd = WeatherData()
wd.read(line.strip().split(','))
self.add_weatherdata(wd)


def read(self, path):
"""Read EPW weather data from file at path.

Args:
path (str): path to read weather data from

"""
with open(path, "r") as f:
self.read_string_io(f)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_read.py → test/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def tearDown(self):
def test_read_epw(self):

epw = EPW()
epw.read(r"tests/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")
epw.read(r"test/data/USA_CA_San.Francisco.Intl.AP.724940_TMY3.epw")

epw.save(self.path)
epw2 = EPW()
Expand Down