get relative path of file python code example
Example 1: python extract thefile name from relative path
import os
infile = "./../../../../_data/matrix_data/5mer_normalized.tsv"
print(os.path.basename(infile))
>>> "5mer_normalized.tsv"
Example 2: relative path python
import sys,os
sys.path.append(os.path.realpath('..'))