# Path to persistent files?

**URL:** <https://discuss.huggingface.co/t/path-to-persistent-files/98848>\
**Category:** Beginners\
**Created:** [July 23, 2024, 1:05am UTC](https://discuss.huggingface.co/t/path-to-persistent-files/98848 "2024-07-23T01:05:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlflannery](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dlflannery](https://discuss.huggingface.co/u/dlflannery)\
**Post date:** [July 23, 2024, 1:05am UTC](https://discuss.huggingface.co/t/path-to-persistent-files/98848/1 "2024-07-23T01:05:14Z")

</div>

I’m running a python program in a Gradio space. I want to use persistent storage to create, read, write a small text file to track usage across different sessions. For testing purposes I’m only trying to use the free (non-persistent) storage. So my program creates, writes to and reads from the small text file all within a current session. When I get it working I will subscribe to paid persistent storage.

I’m told the folder for storage is /data but I cannot figure out how to compose a valid path to a file (example “userLog.txt” ) in this folder. Anything I try just throws an exception when trying to open and use the file.

Can someone clue me in here? TIA

---

<div class="post-metadata">

**Author:** ![dlflannery](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@dlflannery](https://discuss.huggingface.co/u/dlflannery)\
**Post date:** [July 23, 2024, 6:45pm UTC](https://discuss.huggingface.co/t/path-to-persistent-files/98848/2 "2024-07-23T18:45:43Z")

</div>

I figured it out, so if it will help any other noobs I post it here:

1. Create a directory for the file::

from pathlib import Path  
dp = Path(‘…/data’)  
dp.mkdir(exist\_ok=True) # does nothing if dir already exists

1. Then file ops (open, read, write) will succeed with file paths such as:

dataLogFilePath = “…/data/usageData.txt”

EDIT: Discovered by trial and error (after setting up persistent storage) that to access that storage you need: ‘/data’ in the places where I had ‘…/data’ above.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [July 24, 2024, 6:46am UTC](https://discuss.huggingface.co/t/path-to-persistent-files/98848/3 "2024-07-24T06:46:29Z")

</div>

Closed on July 24, 2024, 6:46am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
