Home > database >  CSV file can't be read using great expectation
CSV file can't be read using great expectation

Time:03-29

when I run this code on pycharm using python:

import great_expectations as ge df=ge.read_csv("C:\Users\TasbeehJ\data\yellow_tripdata_2019-02.csv")

it gave me this error:

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

how to solve it?

CodePudding user response:

The esiast way whould be to add an r to use the \as a sign and not an escape value.

import great_expectations as ge 
df=ge.read_csv(r"C:\Users\TasbeehJ\data\yellow_tripdata_2019-02.csv")

CodePudding user response:

You can try by looking here, https://docs.python.org/3.7/library/csv.html?highlight=csv#module-csv

Maybe you can try writing:

>>> import csv 
>>> with open('yellow_tripdata_2019-02.csv', newline='') as csvfile:
  • Related