# Hide CSV files on Spaces

**URL:** <https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329>\
**Category:** Spaces\
**Created:** [March 8, 2023, 11:00am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329 "2023-03-08T11:00:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bradley6597](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bradley6597](https://discuss.huggingface.co/u/bradley6597)\
**Post date:** [March 8, 2023, 11:00am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/1 "2023-03-08T11:00:09Z")

</div>

Is there a way to hide csv files on Spaces to prevent users from being able to download them? I’m aware you can add secrets but that doesn’t seem to cover files?

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](https://discuss.huggingface.co/u/radames)\
**Post date:** [March 9, 2023, 7:46am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/2 "2023-03-09T07:46:19Z")

</div>

Hi @bradley6597, here’s a quick trick to get protected files on a public Space

1. Create a new dataset/model
2. Use the `huggingface_hub` library to clone the dataset/model on the path you’re running the script from
3. Dont forget to add the secret `HUGGING_FACE_HUB_TOKEN` to your Space secrets so `Repository` can authenticate `token=True`, you can also pass the token e.g `token=os.environ["HUB_TOKEN"]`

example

```python
from huggingface_hub import Repository

repo = Repository(
    local_dir="secret-csvs",
    repo_type="dataset",
    clone_from="radames/secret-csvs",
    token=True
)
repo.git_pull()

```

Now you can read you files from the `secret-csvs` folder

---

<div class="post-metadata">

**Author:** ![bradley6597](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bradley6597](https://discuss.huggingface.co/u/bradley6597)\
**Post date:** [March 9, 2023, 9:09am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/3 "2023-03-09T09:09:15Z")

</div>

> [@radames](#):
>
> - Use the `huggingface_hub` library to clone the dataset/model on the path you’re running the script from

Thanks @radames!

I ended up following the same principles and used this code instead

```auto
from datasets import load_dataset
from huggingface_hub import login

login(token = os.environ['HUB_TOKEN'])
dataset = load_dataset("hugging/face/path")

```

---

<div class="post-metadata">

**Author:** ![JunchuanYu](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/junchuanyu/32/15315_2.png) [@JunchuanYu](https://discuss.huggingface.co/u/JunchuanYu)\
**Post date:** [April 11, 2023, 9:14am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/4 "2023-04-11T09:14:23Z")

</div>

> [@radames](#):
>
> Hi @bradley6597, here’s a quick trick to get protected files on a public Space

I’m a new fan of HF and I had a similar problem if I wanted to import a utils.py file from private Space. How should I operate it?

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [April 11, 2023, 2:27pm UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/5 "2023-04-11T14:27:45Z")

</div>

Hi @JunchuanYu ! The code snippet shared above @radames should work for your use case as well. But since you only have one file, I think you can use hf\_hub\_download in your `app.py`.

> **[Download files from the Hub](https://huggingface.co/docs/huggingface_hub/guides/download#download-a-single-file)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![bradley6597](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bradley6597](https://discuss.huggingface.co/u/bradley6597)\
**Post date:** [April 17, 2023, 10:11am UTC](https://discuss.huggingface.co/t/hide-csv-files-on-spaces/33329/6 "2023-04-17T10:11:12Z")

</div>

Hey @freddyaboulton, how would you then call functions within the file after using hf\_hub\_download as it’s in the cache?
