Search code examples
pythonrpandasreadr

How can I read a txt file with µ as delimiter?


I have a txt file which I would like to read in either Python or R (does not matter).

I tried in R to change the locale with readr package, which can read the µ properly when changing to e.g.

data<- read_delim("./weirdfile.txt","µ", escape_double = FALSE, locale = locale(encoding = "ISO-8859-1"), 
    trim_ws = TRUE)

However the above solution does not use "µ" as delimiter.


Solution

  • Use this as the code for mu:

    CSV file:
    clientμdatetime
    abcμabc
    
    DELIMITER = '\u03BC'
    df = pd.read_csv('test.csv', sep=DELIMITER)
    print(df)
    
      client datetime
    0    abc      abc