Datasets:
Download dataset.py from jblitzar/github-python: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/jblitzar/github-python/resolve/d64b38cb115aca391c855b650ce069932d6c1045/dataset.py
- Command line
-
hf download hf://datasets/jblitzar/github-python@d64b38cb115aca391c855b650ce069932d6c1045/dataset.py
-
curl -L -o dataset.py https://huggingface.co/datasets/jblitzar/github-python/resolve/d64b38cb115aca391c855b650ce069932d6c1045/dataset.py
1.38 kB
| import csv | |
| import datasets | |
| class ElaboratedMetadataConfig(datasets.BuilderConfig): | |
| def __init__(self, **kwargs): | |
| super().__init__(**kwargs) | |
| class ElaboratedMetadata(datasets.GeneratorBasedBuilder): | |
| BUILDER_CONFIGS = [ | |
| ElaboratedMetadataConfig(name="default", version=datasets.Version("1.0.0")) | |
| ] | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| features=datasets.Features({ | |
| "owner": datasets.Value("string"), | |
| "repo_name": datasets.Value("string"), | |
| "file_path": datasets.Value("string"), | |
| "url": datasets.Value("string"), | |
| }), | |
| ) | |
| def _split_generators(self, dl_manager): | |
| data_path = dl_manager.download("A_python_files_elaborated_metadata.csv") | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"filepath": data_path}, | |
| ) | |
| ] | |
| def _generate_examples(self, filepath): | |
| with open(filepath, encoding="utf-8") as f: | |
| reader = csv.DictReader(f) | |
| for idx, row in enumerate(reader): | |
| yield idx, { | |
| "owner": row["owner"], | |
| "repo_name": row["repo_name"], | |
| "file_path": row["file_path"], | |
| "url": row["url"], | |
| } | |