ArgumentError while using ```enumerate(CSV.File())```: "..." is not a valid file

julia> for (i,row) in enumerate(CSV.File("/home/devel/Desktop/SDP_me/example/input/misc.csv"))
           println(i)
       end
ERROR: ArgumentError: "/home/devel/Desktop/SDP_me/example/input/misc.csv" is not a valid file
Stacktrace:
 [1] #File#1(::Int64, ::Bool, ::Int64, ::Nothing, ::Int64, ::Nothing, ::Bool, ::Nothing, ::Bool, ::Array{String,1}, ::String, ::String, ::Bool, ::Char, ::Nothing, ::Nothing, ::Char, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Nothing, ::Dict{Type,Type}, ::Symbol, ::Bool, ::Bool, ::Bool, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Type, ::String) at /home/devel/.julia/packages/CSV/eWuJV/src/CSV.jl:135
 [2] Type at /home/devel/.julia/packages/CSV/eWuJV/src/CSV.jl:135 [inlined]
 [3] top-level scope at ./none:0

julia> for (i,row) in enumerate(CSV.File("/home/devel/Desktop/SDP_me/example/input/map.csv"))
           println(i)
       end
1

I checked the file, it’s there safe and sound. So I was deeply confused. (cry…) Can anyone please help me?

That error comes from the very first argument check in the function and it uses Base.isfile to check if the file input is indeed a valid file, so it seems that something is indeed wrong with your file (you can check this yourself by just doing isfile(file) from the REPL).

I mean, from the shell itself, can you navigate to that directory and do ls to list the contents of the directory? Maybe it’s a read permission issue? Just throwing out ideas here.

2 Likes