I was doing something like this, enter image description here
Is there a way that I can read them all at once?
I was doing something like this, enter image description here
Is there a way that I can read them all at once?
I would personally do a dict comprehension for this
root = "drive/Mydrive/"
goodvariable = {f"subject{num}":
{'running': pd.read_csv(f'{root}data/subject_{num}/acc_running_chest.csv'),
'walking': pd.read_csv(f'{root}data/subject_{num}/acc_walking_chest.csv'),
'climbdown': pd.read_csv(f'{root}data/subject_{num}/acc_climbingdown_chest.csv'),
'climbup': pd.read_csv(f'{root}data/subject_{num}/acc_climbingup_chest.csv')}
for num in range(1, 10)
}
In place of 10, a different number can be entered, depending on the number of subjects you have + 1 so if you had 100 subjects, you would have to enter 101. I used 10 because of the image that was supplied (there were 9 subjects, 9+1 = 10). This dict comprehension should give you a dictionary of this structure:
{
"subject1": {
"running": csv_read data from acc_running_chest for subject 1,
"walking": csv_read data from acc_walking_chest for subject 1,
"climbdown": csv_read data from acc_climbingup_chest for subject 1,
"climbup": csv_read data from acc_climbingup_chest for subject 1
},
"subject2": {
... and so on
}
}
You can then access it with:
goodvariable['subject1']['walking'] # csv data of acc_walking_chest for subject 1