Problem with file import (dir does not exist)


#1

Hi everybody,

Brand new to Julia, so please forgive the ignorance. I’m trying to do something simple, i.e. import a local csv file, and am running into problems:

using DataFrames;
data = DataFrames.readtable(“C:\TempPath\test.csv”)

SystemError: opening file C:\TempPath\test.csv: No such file or directory

in #systemerror#51 at ./error.jl:34 [inlined]
in systemerror(::String, ::Bool) at ./error.jl:34
in open(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./iostream.jl:89
in open(::String, ::String) at ./iostream.jl:101
in #readtable#79(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::DataFrames.#readtable, ::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:941
in readtable(::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:930

I have been trying to follow along with blog post (i.e. https://www.r-bloggers.com/tabular-data-io-in-julia/), but can’t figure out why I can’t get past the first step. I’ve tried Python literals, double \s, /s, all to no avail. I know that there must be a simple step I am overlooking…

Thank you in advance, and looking forward to your thoughts.


#2

"\" is wrong. \\ or / will work

try

DataFrames.readtable("C:\\TempPath\\test.csv")

or

DataFrames.readtable("C:/TempPath/test.csv")

#3

Ah, so the syntax is R-like, good to know. Thank you for your help!


#4

Unfortunately:

DataFrames.readtable(“C:/TempPath/test.csv”)
SystemError: opening file C:/TestPath/test.csv: No such file or directory

in #systemerror#51 at ./error.jl:34 [inlined]
in systemerror(::String, ::Bool) at ./error.jl:34
in open(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./iostream.jl:89
in open(::String, ::String) at ./iostream.jl:101
in #readtable#79(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::DataFrames.#readtable, ::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:941
in readtable(::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:930

and

data = DataFrames.readtable(“C:\TempPath\test.csv”)

in #systemerror#51 at ./error.jl:34 [inlined]
in systemerror(::String, ::Bool) at ./error.jl:34
in open(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./iostream.jl:89
in open(::String, ::String) at ./iostream.jl:101
in #readtable#79(::Bool, ::Char, ::Array{Char,1}, ::Char, ::Array{String,1}, ::Array{String,1}, ::Array{String,1}, ::Bool, ::Int64, ::Array{Symbol,1}, ::Array{Any,1}, ::Bool, ::Char, ::Bool, ::Int64, ::Array{Int64,1}, ::Bool, ::Symbol, ::Bool, ::Bool, ::DataFrames.#readtable, ::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:941
in readtable(::String) at /opt/julia_packages/.julia/v0.5/DataFrames/src/dataframe/io.jl:930

I know that the Julia console itself can read the directory:

julia> readdir(“C:\TempPath”)
2-element Array{String,1}:
“newhlmdata.csv”
“test.csv”

Oddly, the same command does not work in JuliaBox:

readdir(“C:\TempPath”)
SystemError: unable to read directory C:\TempPath: No such file or directory

in readdir(::String) at ./file.jl:303

So, in short, still not sure what’s going on…