# Julia CSV.read stopped working

**URL:** <https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247>\
**Category:** Data\
**Tags:** csv\
**Created:** [April 29, 2022, 9:35am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247 "2022-04-29T09:35:58Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 29, 2022, 7:33pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/21 "2022-04-29T19:33:27Z")

</div>

This is what I got:  
\_ \_ _(_)\_ | Documentation: [https://docs.julialang.org](https://docs.julialang.org)  
(_) | (_) (_) |  
\_ \_ | | \_\_ \_ | Type “?” for help, “]?” for Pkg help.  
| | | | | | |/ ` | |  
| | || | | | (_| | | Version 1.6.5 (2021-12-19)  
_/ |\ __‘_|_|_|\__ ’\_| | Official [https://julialang.org/](https://julialang.org/) release  
|\_\_/ |

julia\> using Pkg

julia\> Pkg.activate(; temp = true)  
Activating new environment at `/var/folders/s1/mfq8vx4d63539vgg51kjcms00000gn/T/jl_QI8qVL/Project.toml`

julia\> Pkg.add([“CSV”, “DataFrames”])  
Updating registry at `~/.julia/registries/General`  
Resolving package versions…  
Updating `/private/var/folders/s1/mfq8vx4d63539vgg51kjcms00000gn/T/jl_QI8qVL/Project.toml`  
[336ed68f] + CSV v0.10.4  
[a93c6f00] + DataFrames v1.3.3  
Updating `/private/var/folders/s1/mfq8vx4d63539vgg51kjcms00000gn/T/jl_QI8qVL/Manifest.toml`  
[336ed68f] + CSV v0.10.4  
[944b1d66] + CodecZlib v0.7.0  
[34da2185] + Compat v3.43.0  
[a8cc5b0e] + Crayons v4.1.1  
[9a962f9c] + DataAPI v1.10.0  
[a93c6f00] + DataFrames v1.3.3  
[864edb3b] + DataStructures v0.18.11  
[e2d170a0] + DataValueInterfaces v1.0.0  
[48062228] + FilePathsBase v0.9.18  
[59287772] + Formatting v0.4.2  
[842dd82b] + InlineStrings v1.1.2  
[41ab1584] + InvertedIndices v1.1.0  
[82899510] + IteratorInterfaceExtensions v1.0.0  
[e1d29d7a] + Missings v1.0.2  
[bac558e1] + OrderedCollections v1.4.1  
[69de0a69] + Parsers v2.3.1  
[2dfb63ee] + PooledArrays v1.4.1  
[08abe8d2] + PrettyTables v1.3.1  
[189a3867] + Reexport v1.2.2  
[91c51154] + SentinelArrays v1.3.12  
[a2af1166] + SortingAlgorithms v1.0.1  
[3783bdb8] + TableTraits v1.0.1  
[bd369af6] + Tables v1.7.0  
[3bb67fe8] + TranscodingStreams v0.9.6  
[ea10d353] + WeakRefStrings v1.4.2  
[0dad84c5] + ArgTools  
[56f22d72] + Artifacts  
[2a0f44e3] + Base64  
[ade2ca70] + Dates  
[8bb1440f] + DelimitedFiles  
[8ba89e20] + Distributed  
[f43a241f] + Downloads  
[9fa8497b] + Future  
[b77e0a4c] + InteractiveUtils  
[b27032c2] + LibCURL  
[76f85450] + LibGit2  
[8f399da3] + Libdl  
[37e2e46d] + LinearAlgebra  
[56ddb016] + Logging  
[d6f4376e] + Markdown  
[a63ad114] + Mmap  
[ca575930] + NetworkOptions  
[44cfe95a] + Pkg  
[de0858da] + Printf  
[3fa0cd96] + REPL  
[9a3f8284] + Random  
[ea8e919c] + SHA  
[9e88b42a] + Serialization  
[1a1011a3] + SharedArrays  
[6462fe0b] + Sockets  
[2f01184e] + SparseArrays  
[10745b16] + Statistics  
[fa267f1f] + TOML  
[a4e569a6] + Tar  
[8dfed614] + Test  
[cf7118a7] + UUIDs  
[4ec0a83e] + Unicode  
[deac9b47] + LibCURL\_jll  
[29816b5a] + LibSSH2\_jll  
[c8ffd9c3] + MbedTLS\_jll  
[14a3606d] + MozillaCACerts\_jll  
[83775a58] + Zlib\_jll  
[8e850ede] + nghttp2\_jll  
[3f19e933] + p7zip\_jll  
Precompiling project…  
5 dependencies successfully precompiled in 4 seconds (23 already precompiled)

julia\> using CSV, DataFrames

julia\> CSV.read(“ICloud Drive/Desktop/Werk/Sydney/Ospats-plus/+RegrEst/Code+RegrEst/Codes Ospats-plus/NowleyT.txt”, DataFrame; delim = ‘,’, header = false)  
ERROR: ArgumentError: “ICloud Drive/Desktop/Werk/Sydney/Ospats-plus/+RegrEst/Code+RegrEst/Codes Ospats-plus/NowleyT.txt” is not a valid file or doesn’t exist  
Stacktrace:  
[1] CSV.Context(source::CSV.Arg, header::CSV.Arg, normalizenames::CSV.Arg, datarow::CSV.Arg, skipto::CSV.Arg, footerskip::CSV.Arg, transpose::CSV.Arg, comment::CSV.Arg, ignoreemptyrows::CSV.Arg, ignoreemptylines::CSV.Arg, select::CSV.Arg, drop::CSV.Arg, limit::CSV.Arg, buffer\_in\_memory::CSV.Arg, threaded::CSV.Arg, ntasks::CSV.Arg, tasks::CSV.Arg, rows\_to\_check::CSV.Arg, lines\_to\_check::CSV.Arg, missingstrings::CSV.Arg, missingstring::CSV.Arg, delim::CSV.Arg, ignorerepeated::CSV.Arg, quoted::CSV.Arg, quotechar::CSV.Arg, openquotechar::CSV.Arg, closequotechar::CSV.Arg, escapechar::CSV.Arg, dateformat::CSV.Arg, dateformats::CSV.Arg, decimal::CSV.Arg, truestrings::CSV.Arg, falsestrings::CSV.Arg, stripwhitespace::CSV.Arg, type::CSV.Arg, types::CSV.Arg, typemap::CSV.Arg, pool::CSV.Arg, downcast::CSV.Arg, lazystrings::CSV.Arg, stringtype::CSV.Arg, strict::CSV.Arg, silencewarnings::CSV.Arg, maxwarnings::CSV.Arg, debug::CSV.Arg, parsingdebug::CSV.Arg, validate::CSV.Arg, streaming::CSV.Arg)  
@ CSV ~/.julia/packages/CSV/jFiCn/src/context.jl:236  
[2] #File#25  
@ ~/.julia/packages/CSV/jFiCn/src/file.jl:221 [inlined]  
[3] read(source::String, sink::Type; copycols::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:delim, :header), Tuple{Char, Bool}}})  
@ CSV ~/.julia/packages/CSV/jFiCn/src/CSV.jl:91  
[4] top-level scope  
@ REPL[5]:1

julia\>

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 29, 2022, 8:17pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/22 "2022-04-29T20:17:23Z")

</div>

Okay, so the file path is incorrect. Can you `cd` into the directory in which the file is located and just do `CSV.read("NowleyT.txt", DataFrame; delim = ',', header = false)`?

---

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 29, 2022, 8:45pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/23 "2022-04-29T20:45:10Z")

</div>

What do you mean with “cd into the directory”?

---

<div class="post-metadata">

**Author:** ![ArchieCall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/archiecall/32/206_2.png) [@ArchieCall](https://discourse.julialang.org/u/ArchieCall)\
**Post date:** [April 29, 2022, 8:53pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/24 "2022-04-29T20:53:33Z")

</div>

Do help in the REPL on “cd”, and you will get the idea.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 29, 2022, 9:17pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/25 "2022-04-29T21:17:37Z")

</div>

I mean use the `cd` function to move to the directory that holds your file:

```julia
julia> pwd()
"/home/nils"

julia> cd("/home/nils/Documents")

julia> pwd()
"/home/nils/Documents"

```

`pwd()` tells you which directory you’re in, `cd` lets you switch directories.

---

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 30, 2022, 7:09am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/26 "2022-04-30T07:09:19Z")

</div>

This is what I did and got: **julia\>** cd(“Codes Ospats-plus”)

**julia\>** pwd()

“/Users/jjdegruijter/Desktop/Werk/Sydney/Ospats-plus/+RegrEst/code +RegrEst/Codes Ospats-plus”

**julia\>** CSV.read(“NowleyT.txt”, DataFrame; delim = ‘,’, header =false)

**ERROR:** UndefVarError: CSV not defined

Stacktrace:

[1] top-level scope

@ REPL[16]:1

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [April 30, 2022, 7:13am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/27 "2022-04-30T07:13:22Z")

</div>

but have you done `using CSV` in the same session?

---

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 30, 2022, 7:35am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/28 "2022-04-30T07:35:30Z")

</div>

**julia\>** using CSV

**julia\>** CSV.read(“NowleyT.txt”, DataFrame; delim = ‘,’, header =false)

**ERROR:** UndefVarError: DataFrame not defined

Stacktrace:

[1] top-level scope

@ REPL[18]:1

**julia\>** CSV.read(“NowleyT.txt”, DataFrames; delim = ‘,’, header =false)

**ERROR:** UndefVarError: DataFrames not defined

Stacktrace:

[1] top-level scope

@ REPL[19]:1

**julia\>** using DataFrames

**julia\>** CSV.read(“NowleyT.txt”, DataFrames; delim = ‘,’, header =false)

**ERROR:** MethodError: objects of type Module are not callable

Stacktrace:

[1] **|\>(** x::Tables.CopiedColumns{CSV.File}, f::Module **)**

@ Base ./operators.jl:858

[2] **read(** source::String, sink::Module; copycols::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:delim, :header), Tuple{Char, Bool}}} **)**

@ CSV ~/.julia/packages/CSV/0Elut/src/CSV.jl:91

[3] top-level scope

@ REPL[21]:1

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [April 30, 2022, 7:51am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/29 "2022-04-30T07:51:10Z")

</div>

You need `using CSV` _and_ `using DataFrames`.

It seems you should read more tutorials to understand how package management works. And how to use Julia more broadly. I get the sense you are frequently starting new sessions and assuming things will start back where you left off. This is not the case. You need to re-run the startup code Nils gave you every time you start a new session in order to re-produce your problem.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 30, 2022, 9:27am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/30 "2022-04-30T09:27:24Z")

</div>

While I completely agree with Peter, can you do the following:

1. Copy the `NowleyT.txt` into the “Codes Ospats-plus” folder using your operating system’s file explorer

2. Start a new Julia session.

3. Run:

```julia
cd("Codes Ospats-plus")
pwd()
@assert isfile("NowleyT.txt")
using Pkg; Pkg.add(["CSV", "DataFrames"])
using CSV, DataFrames
CSV.read("NowleyT.txt", DataFrame; delim = `,`, header = false)

```

---

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 30, 2022, 10:31am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/31 "2022-04-30T10:31:14Z")

</div>

I did what Nils told me to do, and HOERA! This is what I got:

**julia\>** cd(“Codes Ospats-plus”)

**julia\>** pwd()  
“/Users/jjdegruijter/Desktop/Werk/Sydney/Ospats-plus/+RegrEst/code +RegrEst/Codes Ospats-plus”

**julia\>** @assert isfile(“NowleyT.txt”)

**julia\>** using Pkg; Pkg.add([“CSV”, “DataFrames”])  
**Updating** registry at `~/.julia/registries/General`  
**Resolving** package versions…  
**No Changes** to `~/.julia/environments/v1.6/Project.toml`  
**No Changes** to `~/.julia/environments/v1.6/Manifest.toml`

**julia\>** using CSV, DataFrames

**julia\>** CSV.read(“NowleyT.txt”, DataFrame; delim = ‘,’, header = false)  
**30×5 DataFrame**  
**Row** │ **Column1 Column2 Column3 Column4 Column5**  
│ Float64 Float64 Int64 Float64 Float64  
─────┼───────────────────────────────────────────────────  
1 │ 1.51181e6 -3.6314e6 134 14.0385 1.58793  
2 │ 1.51188e6 -3.6314e6 135 14.0623 1.63998  
3 │ 1.51196e6 -3.6314e6 136 13.8402 1.48364  
4 │ 1.51173e6 -3.63148e6 248 14.308 1.81295  
5 │ 1.51181e6 -3.63148e6 249 14.271 1.7802  
6 │ 1.51188e6 -3.63148e6 250 14.2896 1.79292  
7 │ 1.51196e6 -3.63148e6 251 13.9846 1.55426  
8 │ 1.51203e6 -3.63148e6 252 13.1979 1.12702  
⋮ │ ⋮ ⋮ ⋮ ⋮ ⋮  
24 │ 1.51256e6 -3.63155e6 374 11.035 1.17459  
25 │ 1.51263e6 -3.63155e6 375 11.3989 1.40901  
26 │ 1.51271e6 -3.63155e6 376 11.6166 1.72427  
27 │ 1.51166e6 -3.63163e6 477 12.962 1.01452  
28 │ 1.51173e6 -3.63163e6 478 13.1085 1.26399  
29 │ 1.51181e6 -3.63163e6 479 14.3835 2.01886  
30 │ 1.51188e6 -3.63163e6 480 14.8844 2.29299  
15 rows omitted

---

<div class="post-metadata">

**Author:** ![jjdegruijter](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jjdegruijter](https://discourse.julialang.org/u/jjdegruijter)\
**Post date:** [April 30, 2022, 10:45am UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/32 "2022-04-30T10:45:22Z")

</div>

Thank you very much for your help and all your patience!

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 30, 2022, 1:19pm UTC](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247/33 "2022-04-30T13:19:29Z")

</div>

Glad this worked! Doesn’t really solve the original mystery of why instead of error messages you were shown the content of the file in which the error occurred, but if that happens again please start a new thread.

[Previous page](https://discourse.julialang.org/t/julia-csv-read-stopped-working/80247.md?page=1)
