Syntax error

i get syntax error while importing csv file 

File "<ipython-input-59-651aefa4aa33>", line 3
    infy = pd.read_csv("C:\Users\hp\Downloads\infy.csv")
                      ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape


please help me to solve this error

Please see below different ways to fix the error.
 
  1. Just put r before the path:
    read_csv(r"C:\Users\hp\Downloads\infy.csv")
     
  2. Use forward slash instead of bacward slash
    read_csv("C:/Users/hp/Downloads/infy.csv")
     
  3. Use double backward slash
    read_csv("C:\\Users\\hp\\Downloads\\infy.csv")

I hope this helps!

Thanks
Team Quantra

i used this 3 different ways but still it did not work it shows the same error

Hi Vishal, Since the above solution is not working, a possible workaround would be to store the infy.csv file in same folder where you have stored the code (.py) file. Then, you can read the csv file without mentioning the full path as pd.read_csv(‘infy.csv’). Thanks!