When running the code below, I got the error message saying 'TypeError: expected str, bytes or os.PathLike object, not list'
I used Spyder to debug the above error message - but I could not find the bug. Could someone please tell me how to solve this error? The code is given below
Thank you!
J1 = ['520A','520B']
J2 = ['560S','580A']
JOINTS = J1 + J2
FILES_IN = ['dynres-x-eqk.lst','dynres-y-eqk.lst','dynres-z-eqk.lst']
FILE_OUT = ['_Accelerations.txt']
def joint_acc(joint, file_in):
output = []
with open(file_in, 'rt') as f_in:
for line in f_in:
if 'JOINT ACCELERATIONS' in line:
for line in f_in:
if line.startswith(joint):
while line.strip() != '':
output.append(line)
line = next(f_in)
break
return ''.join(output)
with open(FILE_OUT, 'wt') as f_out:
for Jt in JOINTS:
for filename in FILES_IN:
f_out.write(joint_acc(Jt, filename))
f_out.write('\n')