0
File "C:\Users\installer\AppData\Local\Temp\ipykernel_3512\4224178993.py", line 2
    with open("C:\Users\installer\Downloads\KAwipOX8RpSMIqTl_PaU6w_47d4fbc49f90412180f9f19727e222cc_Mod-1-Code-Data-Files (1)\Mod 1 Code & Data Files\albumlist.csv", "r") as csvfile:
                                                                                                                                                                    ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
import csv
with open("C:\Users\installer\Downloads\KAwipOX8RpSMIqTl_PaU6w_47d4fbc49f90412180f9f19727e222cc_Mod-1-Code-Data-Files (1)\Mod 1 Code & Data Files\albumlist.csv", "r") as csvfile:
    reader=csv.dictreader(csvfile)
    
    print(type(reader))
    print(reader.fieldnames)

it was supposed to give me this <class 'csv.DictReader'> ['Number', 'Year', 'Album', 'Artist', 'Genre', 'Subgenre']

kithuto
  • 455
  • 2
  • 11
David
  • 1
  • 1
  • Look into using raw strings in your Windows paths with Python, see [here](https://stackoverflow.com/a/25650185/8508004) and [here](https://stackoverflow.com/a/2953843/8508004). – Wayne Feb 24 '23 at 13:12
  • Without a raw string, in `\Users` the `\U` is expected to be the start of an 8-digit Unicode escape code. – Mark Tolonen Feb 25 '23 at 16:59

0 Answers0