# How to create subset when pushing to hub

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542%3E%5C
**Category:** 🤗Datasets\
**Created:** [June 23, 2022, 5:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542 "2022-06-23T17:35:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrielsantosrv](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gabrielsantosrv/32/5151_2.png) [@gabrielsantosrv](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgabrielsantosrv)%5C
**Post date:** [June 23, 2022, 5:35pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542%2F1 "2022-06-23T17:35:29Z")

</div>

Hey!

I have a dataset of image and text, and I am trying to upload it to the hub using the script below. I was wondering how to create a subset, because everything is been put in “_gabrielsantosrv–pracegover_” subset.

Thanks in advance 😃

```auto
from datasets import Dataset, load_dataset
from PIL import Image
import io
import json

def try_load_image(filepath):
    try:
        with open(filepath, 'rb') as f:
            image = Image.open(io.BytesIO(f.read()))
        if isinstance(image, Image.Image):
            return image
    except Image.UnidentifiedImageError:
        return None

if __name__ == " __main__":
    split = "demo"
    filepath = "sample/dataset_sample.json"
    dataset = load_dataset('json', data_files=filepath, field="data")
    dataset[split] = dataset.pop("train") # renaming key from train to `split`

    dataset["demo"].map(lambda example: {"img": try_load_image(f"sample/images/{example['filename']}")})

    repo = "gabrielsantosrv/pracegover"
    dataset.push_to_hub(repo)

```

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmariosasko)%5C
**Post date:** [June 24, 2022, 1:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542%2F2 "2022-06-24T13:17:33Z")

</div>

Hi! No-code dataset repositories created with `push_to_hub` (or by pushing raw data files) currently support only a single config/sub-dataset, so you’ll have to write a generation script to get more than one config.

---

<div class="post-metadata">

**Author:** ![gabrielsantosrv](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/gabrielsantosrv/32/5151_2.png) [@gabrielsantosrv](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgabrielsantosrv)%5C
**Post date:** [June 24, 2022, 5:26pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542%2F3 "2022-06-24T17:26:33Z")

</div>

Hi! Thanks for your reply 😃

Do have any suggestions or example of how I can write a generation script and get more than one config?

---

<div class="post-metadata">

**Author:** ![lhoestq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lhoestq/32/64813_2.png) [@lhoestq](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Flhoestq)%5C
**Post date:** [June 27, 2022, 2:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-create-subset-when-pushing-to-hub%2F19542%2F4 "2022-06-27T14:17:25Z")

</div>

You can find some docs on how to write a dataset script here: [Create a dataset loading script](https://huggingface.co/docs/datasets/dataset_script)

There is also a section called “Multiple configurations” that can help you 😉
