0

I am currently trying to use pandas to read what is basically a csv file (but officially .dat format) and plot the data inside.

def IofQ(folderout) : 
    Iofq = pd.read_csv("{}\Iofq.dat".format(folderout), sep='\t')    
    Graph = Iofq.plot()
    
    return Iofq
IofQ("E:\ECOLE\Stage_L2C_Backup\ESA_COLIS\25_07_2023_101output\R01154_long\OutputSALS\dunno")

However, when I call this function, I get the error :

OSError: [Errno 22] Invalid argument: 'E:\\ECOLE\\Stage_L2C_Backup\\ESA_COLIS\x15_07_2023_101output\\R01154_long\\OutputSALS\\dunno\\Iofq.dat'

As you can see, the date 25_07_2023 is read x15_07 by the system and I have no idea why. On top of this, if the path was wrong, the error would something like could not find directory I guess.

Does someone know where such an error comes from ?

Archerlite
  • 25
  • 4
  • 1
    Specifically, `\25` in a non-raw string literal is interpreted as an escape sequence to mean the single character with character code 25 in base-8 (i.e. 21 in base-10 and 15 in hexadecimal, which is why you see `\x15`). As per the linked question, you can fix this by any of (1) putting `r` before the literal to make it a raw string, (2) escaping the backslashes by doubling them, (3) using forward-slash instead of backslash. (For documentation, see the "Escape Sequences" table at https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals) – slothrop Jul 28 '23 at 12:02

0 Answers0