# Making a dataset that read the labels from parent folders

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmaking-a-dataset-that-read-the-labels-from-parent-folders%2F12484%3E%5C
**Category:** Intermediate\
**Created:** [December 2, 2021, 8:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmaking-a-dataset-that-read-the-labels-from-parent-folders%2F12484 "2021-12-02T20:53:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![coldfir3](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@coldfir3](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fcoldfir3)%5C
**Post date:** [December 2, 2021, 8:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmaking-a-dataset-that-read-the-labels-from-parent-folders%2F12484%2F1 "2021-12-02T20:53:57Z")

</div>

I am trying to build a dataset using `load_dataset` for a classification task. The labels are encoded on the parent folder (like /label/file\_1.txt). How can I create that new column with the label? Thanks.

PS: my whole folder structure is (train/valid) / (label) / file\_name.txt so It would be nice if I could get the splits from the grandfather folder.
