Skip to main content

Creating and Loading Files

Saving

from abstra.files import get_persistent_dir

# Get the persistent directory path
files_dir = get_persistent_dir()

# Create and write to a file in the persistent directory
logs = files_dir / 'logs.txt'
logs.write_text('Hello World')

Loading

from abstra.files import get_persistent_dir
from pathlib import Path

# Get the persistent directory path
files_dir = get_persistent_dir()

# Read the file
logs = files_dir / 'logs.txt'
with open(logs, 'r') as file:
content = file.read()
print(content) # Output: Hello World