A
A
adambldor22020-07-19 13:36:22
Python
adambldor2, 2020-07-19 13:36:22

How to fix error when importing multiple Pandas files?

I'm trying to load multiple csv files whose names start the same using pandas. When these files are in the same folder as the code, the import succeeds:

df2 = pd.concat([pd.read_csv(f) for f in glob.glob('d_union*.csv')])

But if I try to upload a file from an external folder, I get an error:
df2 = pd.concat([pd.read_csv(f) for f in glob.glob('C:\Users\gorar\Documents\work\task1\dog_2020_06_11\d_union*.csv')])

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
adambldor2, 2020-07-19
@adambldor2

I found a solution, you need to put slashes in the other direction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question