I need to analyze data in some folders.
I do it using Python. I need to move into directories named /a0_0.68410 or /a0_0.68423 , or similar. The names of the folders are all in the form 0.xyztu, 5 digits after the decimal. The folders exist already.
Some lines from the code read:
Intensity_versus_a0_path = os.getcwd() + "/Intensity_Wcm2_versus_a0_10_18_10_19_range.txt"
a0_s = np.loadtxt(Intensity_versus_a0_path, usecols=(1,)) # a0_s[2] is 0.68410 inside the .txt file
top_folder_path = os.getcwd()
for i in range(10):
a0_folder_path= top_folder_path + "/a0_" + str(a0_s[i])
os.chdir(a0_folder_path)
# do_something
os.chdir(top_folder_path)
I get an error:
File "charge_state_distr_10000datapoints.py", line 28, in <module>
os.chdir(a0_folder_path)
FileNotFoundError: [Errno 2] No such file or directory: '/lus/cls01095/work/e674/e674/ouatu/Smiliei_top_folder/Smilei/SIMULATION_RESULTS/10_18_10_19_200ppc_1Dim/a0_0.6841'
The error is because I want to access a folder called a0_6841, which does not exist. The folder which exists indeed is called a0_68410.
What shall I do to access these type of folders, with their name ending in a 0?
I have tried with Decimal module, but it doesn't work (or I don't know how to use it)