Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using "r" for escape sequence when file in Julia

On the Python using r front of the file path, can deal with escape sequence such as :

   df = pd.read_csv(r"D:\datasets\42133.csv")

However on Julia, the below code returns, MethodError: no method matching joinpath(::Regex)

file_path = r"D:\datasets\42133.csv"
df = DataFrame(CSV.File(file_path))

I checked this, and know that I can chage \ to \\ or /. But wondering that why Julia does not allowed to use r"String"? Also is there something like r"String" on Julia?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are looking for raw"..." string.

julia> raw"D:\datasets\42133.csv"
"D:\\datasets\\42133.csv"

In Julia, r"..." strings create a Regex object.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading