I can extract a string from a .json file:
path1 --> "../../Images/PatientID 0/1.2.840.113704.1.111.2716.1398172953.1/1.2.840.113704.1.111.2716.1398173172.21"
The Images
folder above is in path2 --> D:\\\\CAP Exam Data\
path(windows).
I want to remove the ../../
part and join path1 and path2 to access the file from a python script.
I have tried the following:
path1 = '../../Images/PatientID 0/1.2.840.113704.1.111.2716.1398172953.1/1.2.840.113704.1.111.2716.1398173172.21'
path2 = ''D:\\\\CAP Exam Data\
newpath = os.path.join(path2, path1)
print(newpath)
D:\\CAP Exam Data\../../Images/9111142/1.2.840.113745.101000.100100.2.41057.5995.9117440/1.3.12.2.1107.5.1.4.60044.30000012053010493246800022943
Now how do I remove ../../
part? I tried slicing like [4:]
in path1.
But nothing seems to work.
Also, how can I fix up the /
\
windows, Linux conflict? Is it even an issue?