I pulled and saved a few requests.get json files via a for loop function and now I want to create another for loop that pulls each json file and converts them into a dataframe. The for loop snippet below isn't complete as I cannot continue testing it with the below syntax error.
How do I alter the last part of the path via a for loop?
Also, is it best when dealing with multiple files to create one huge master loop that goes through the entire process one at a time and then proceeds with the next? Or is it better to break each data cleaning/testing step into it's own for loop?
file_list = ["API A", "API B", "API C"]
for file in file_list:
df = pd.read_json(r'C:\Users\username\'+file)
print(df)
Error:
File "<ipython-input-72-b9019f051ed3>", line 2
df = pd.read_json(r'C:\Users\username\'+file_list)
^
SyntaxError: EOL while scanning string literal