Open this example in the interactive library
Source code
from pathlib import PurePosixPath
print(PurePosixPath('/app/data/file.csv').relative_to('/app'))Sample output
data/file.csv

Calculate a relative path. A self-contained example using the Python standard library.
Open this example in the interactive library
from pathlib import PurePosixPath
print(PurePosixPath('/app/data/file.csv').relative_to('/app'))data/file.csv