def _import_data(self, import_header_only=False):
<EOL>assert os.path.isfile(self._file_path), '<STR_LIT>'.format(<EOL>self._file_path)<EOL>assert self._file_path.lower().endswith('<STR_LIT>'), '<STR_LIT>''<STR_LIT>'.format(self._file_path)<EOL>with open(self._file_path, readmode) as epwin:<EOL><INDENT>line = epwin.readline()<EOL>original_header_load = bool(self._is_header_loaded)<EOL>if not self._is_header_loaded:<EOL><INDENT>location_data = line.strip().split('<STR_LIT:U+002C>')<EOL>self._location = Location()<EOL>self._location.city = location_data[<NUM_LIT:1>].replace('<STR_LIT:\\>', '<STR_LIT:U+0020>').replace('<STR_LIT:/>', '<STR_LIT:U+0020>')<EOL>self._location.state = location_data[<NUM_LIT:2>]<EOL>self._location.country = location_data[<NUM_LIT:3>]<EOL>self._location.source = location_data[<NUM_LIT:4>]<EOL>self._location.station_id = location_data[<NUM_LIT:5>]<EOL>self._location.latitude = location_data[<NUM_LIT:6>]<EOL>self._location.longitude = location_data[<NUM_LIT:7>]<EOL>self._location.time_zone = location_data[<NUM_LIT:8>]<EOL>self._location.elevation = location_data[<NUM_LIT:9>]<EOL>self._metadata = {<EOL>'<STR_LIT:source>': self._location.source,<EOL>'<STR_LIT>': self._location.country,<EOL>'<STR_LIT>': self._location.city<EOL>}<EOL>self._header = [line] + [epwin.readline() for i in xrange(<NUM_LIT:7>)]<EOL>dday_data = self._header[<NUM_LIT:1>].strip().split('<STR_LIT:U+002C>')<EOL>if len(dday_data) >= <NUM_LIT:2> and int(dday_data[<NUM_LIT:1>]) == <NUM_LIT:1>:<EOL><INDENT>if dday_data[<NUM_LIT:4>] == '<STR_LIT>':<EOL><INDENT>for key, val in zip(DesignDay.heating_keys, dday_data[<NUM_LIT:5>:<NUM_LIT:20>]):<EOL><INDENT>self._heating_dict[key] = val<EOL><DEDENT><DEDENT>if dday_data[<NUM_LIT:20>] == '<STR_LIT>':<EOL><INDENT>for key, val in zip(DesignDay.cooling_keys, dday_data[<NUM_LIT>:<NUM_LIT>]):<EOL><INDENT>self._cooling_dict[key] = val<EOL><DEDENT><DEDENT>if dday_data[<NUM_LIT>] == '<STR_LIT>':<EOL><INDENT>for key, val in zip(DesignDay.extreme_keys, dday_data[<NUM_LIT>:<NUM_LIT>]):<EOL><INDENT>self._extremes_dict[key] = val<EOL><DEDENT><DEDENT><DEDENT>week_data = self._header[<NUM_LIT:2>].split('<STR_LIT:U+002C>')<EOL>num_weeks = int(week_data[<NUM_LIT:1>]) if len(week_data) >= <NUM_LIT:2> else <NUM_LIT:0><EOL>st_ind = <NUM_LIT:2><EOL>for i in xrange(num_weeks):<EOL><INDENT>week_dat = week_data[st_ind:st_ind + <NUM_LIT:4>]<EOL>st_ind += <NUM_LIT:4><EOL>st = [int(num) for num in week_dat[<NUM_LIT:2>].split('<STR_LIT:/>')]<EOL>end = [int(num) for num in week_dat[<NUM_LIT:3>].split('<STR_LIT:/>')]<EOL>if len(st) == <NUM_LIT:3>:<EOL><INDENT>a_per = AnalysisPeriod(st[<NUM_LIT:1>], st[<NUM_LIT:2>], <NUM_LIT:0>, end[<NUM_LIT:1>], end[<NUM_LIT:2>], <NUM_LIT>)<EOL><DEDENT>elif len(st) == <NUM_LIT:2>:<EOL><INDENT>a_per = AnalysisPeriod(st[<NUM_LIT:0>], st[<NUM_LIT:1>], <NUM_LIT:0>, end[<NUM_LIT:0>], end[<NUM_LIT:1>], <NUM_LIT>)<EOL><DEDENT>if '<STR_LIT>' in week_dat[<NUM_LIT:0>] and week_dat[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>self._extreme_hot_weeks[week_dat[<NUM_LIT:0>]] = a_per<EOL><DEDENT>elif '<STR_LIT>' in week_dat[<NUM_LIT:0>] and week_dat[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>self._extreme_cold_weeks[week_dat[<NUM_LIT:0>]] = a_per<EOL><DEDENT>elif week_dat[<NUM_LIT:1>] == '<STR_LIT>':<EOL><INDENT>self._typical_weeks[week_dat[<NUM_LIT:0>]] = a_per<EOL><DEDENT><DEDENT>grnd_data = self._header[<NUM_LIT:3>].strip().split('<STR_LIT:U+002C>')<EOL>num_depths = int(grnd_data[<NUM_LIT:1>]) if len(grnd_data) >= <NUM_LIT:2> else <NUM_LIT:0><EOL>st_ind = <NUM_LIT:2><EOL>for i in xrange(num_depths):<EOL><INDENT>header_meta = dict(self._metadata)  <EOL>header_meta['<STR_LIT>'] = float(grnd_data[st_ind])<EOL>header_meta['<STR_LIT>'] = grnd_data[st_ind + <NUM_LIT:1>]<EOL>header_meta['<STR_LIT>'] = grnd_data[st_ind + <NUM_LIT:2>]<EOL>header_meta['<STR_LIT>'] = grnd_data[st_ind + <NUM_LIT:3>]<EOL>grnd_header = Header(temperature.GroundTemperature(), '<STR_LIT:C>',<EOL>AnalysisPeriod(), header_meta)<EOL>grnd_vlas = [float(x) for x in grnd_data[st_ind + <NUM_LIT:4>: st_ind + <NUM_LIT:16>]]<EOL>self._monthly_ground_temps[float(grnd_data[st_ind])] =MonthlyCollection(grnd_header, grnd_vlas, list(xrange(<NUM_LIT:12>)))<EOL>st_ind += <NUM_LIT:16><EOL><DEDENT>leap_dl_sav = self._header[<NUM_LIT:4>].strip().split('<STR_LIT:U+002C>')<EOL>self._is_leap_year = True if leap_dl_sav[<NUM_LIT:1>] == '<STR_LIT>' else False<EOL>self.daylight_savings_start = leap_dl_sav[<NUM_LIT:2>]<EOL>self.daylight_savings_end = leap_dl_sav[<NUM_LIT:3>]<EOL>comments_1 = self._header[<NUM_LIT:5>].strip().split('<STR_LIT:U+002C>')<EOL>if len(comments_1) > <NUM_LIT:0>:<EOL><INDENT>self.comments_1 = '<STR_LIT:U+002C>'.join(comments_1[<NUM_LIT:1>:])<EOL><DEDENT>comments_2 = self._header[<NUM_LIT:6>].strip().split('<STR_LIT:U+002C>')<EOL>if len(comments_2) > <NUM_LIT:0>:<EOL><INDENT>self.comments_2 = '<STR_LIT:U+002C>'.join(comments_2[<NUM_LIT:1>:])<EOL><DEDENT>self._is_header_loaded = True<EOL><DEDENT>if import_header_only:<EOL><INDENT>return<EOL><DEDENT>if original_header_load is True:<EOL><INDENT>for i in xrange(<NUM_LIT:7>):<EOL><INDENT>epwin.readline()<EOL><DEDENT><DEDENT>line = epwin.readline()<EOL>self._num_of_fields = min(len(line.strip().split('<STR_LIT:U+002C>')), <NUM_LIT>)<EOL>analysis_period = AnalysisPeriod(is_leap_year=self.is_leap_year)<EOL>headers = []<EOL>for field_number in xrange(self._num_of_fields):<EOL><INDENT>field = EPWFields.field_by_number(field_number)<EOL>header = Header(data_type=field.name, unit=field.unit,<EOL>analysis_period=analysis_period,<EOL>metadata=dict(self._metadata))<EOL>headers.append(header)<EOL>self._data.append([])<EOL><DEDENT>while line:<EOL><INDENT>data = line.strip().split('<STR_LIT:U+002C>')<EOL>for field_number in xrange(self._num_of_fields):<EOL><INDENT>value_type = EPWFields.field_by_number(field_number).value_type<EOL>try:<EOL><INDENT>value = value_type(data[field_number])<EOL><DEDENT>except ValueError as e:<EOL><INDENT>if value_type != int:<EOL><INDENT>raise ValueError(e)<EOL><DEDENT>value = int(round(float(data[field_number])))<EOL><DEDENT>self._data[field_number].append(value)<EOL><DEDENT>line = epwin.readline()<EOL><DEDENT>for field_number in xrange(self._num_of_fields):<EOL><INDENT>point_in_time = headers[field_number].data_type.point_in_time<EOL>if point_in_time is True:<EOL><INDENT>last_hour = self._data[field_number].pop()<EOL>self._data[field_number].insert(<NUM_LIT:0>, last_hour)<EOL><DEDENT><DEDENT>for i in xrange(self._num_of_fields):<EOL><INDENT>self._data[i] = HourlyContinuousCollection(headers[i], self._data[i])<EOL><DEDENT>self._is_data_loaded = True<EOL><DEDENT>
Import data from an epw file.

        Hourly data will be saved in self.data and the various header data
        will be saved in the properties above.