MCPcopy
hub / github.com/dmlc/dgl / load_from_csv

Method load_from_csv

python/dgl/data/csv_dataset_base.py:215–236  ·  view source on GitHub ↗
(
        meta: MetaEdge, data_parser: Callable, base_dir=None, separator=","
    )

Source from the content-addressed store, hash-verified

213
214 @staticmethod
215 def load_from_csv(
216 meta: MetaEdge, data_parser: Callable, base_dir=None, separator=","
217 ):
218 df = BaseData.read_csv(meta.file_name, base_dir, separator)
219 src_ids = BaseData.pop_from_dataframe(df, meta.src_id_field)
220 if src_ids is None:
221 raise DGLError(
222 "Missing src id field [{}] in file [{}].".format(
223 meta.src_id_field, meta.file_name
224 )
225 )
226 dst_ids = BaseData.pop_from_dataframe(df, meta.dst_id_field)
227 if dst_ids is None:
228 raise DGLError(
229 "Missing dst id field [{}] in file [{}].".format(
230 meta.dst_id_field, meta.file_name
231 )
232 )
233 graph_ids = BaseData.pop_from_dataframe(df, meta.graph_id_field)
234 etype = tuple(meta.etype)
235 edata = data_parser(df)
236 return EdgeData(src_ids, dst_ids, edata, type=etype, graph_id=graph_ids)
237
238 @staticmethod
239 def to_dict(edge_data: List["EdgeData"], node_dict: dict) -> dict:

Callers

nothing calls this directly

Calls 5

DGLErrorClass · 0.85
read_csvMethod · 0.80
pop_from_dataframeMethod · 0.80
formatMethod · 0.80
EdgeDataClass · 0.70

Tested by

no test coverage detected