MCPcopy Create free account
hub / github.com/Vespa314/chan.py / get_kl_data

Method get_kl_data

DataAPI/csvAPI.py:59–76  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

57 super(CSV_API, self).__init__(code, k_type, begin_date, end_date, autype)
58
59 def get_kl_data(self):
60 cur_path = os.path.dirname(os.path.realpath(__file__))
61 k_type = self.k_type.name[2:].lower()
62 file_path = f"{cur_path}/../{self.code}_{k_type}.csv"
63 if not os.path.exists(file_path):
64 raise CChanException(f"file not exist: {file_path}", ErrCode.SRC_DATA_NOT_FOUND)
65
66 for line_number, line in enumerate(open(file_path, 'r')):
67 if self.headers_exist and line_number == 0:
68 continue
69 data = line.strip("\n").split(",")
70 if len(data) != len(self.columns):
71 raise CChanException(f"file format error: {file_path}", ErrCode.SRC_DATA_FORMAT_ERROR)
72 if self.begin_date is not None and data[self.time_column_idx] < self.begin_date:
73 continue
74 if self.end_date is not None and data[self.time_column_idx] > self.end_date:
75 continue
76 yield CKLine_Unit(create_item_dict(data, self.columns))
77
78 def SetBasciInfo(self):
79 pass

Callers

nothing calls this directly

Calls 3

CChanExceptionClass · 0.90
CKLine_UnitClass · 0.90
create_item_dictFunction · 0.70

Tested by

no test coverage detected