Hide CSV files on Spaces

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?

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"]


from huggingface_hub import Repository

repo = Repository(

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

Thanks @radames!

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

from datasets import load_dataset
from huggingface_hub import login

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