Method Error: Cannot read CSV

I am very new to Julia and would appreciate some help with the following. I am trying to read a CSV file into my programme. When I open the CSV Excel, its a 199x7 matrix of numbers. I am using the following code to create a variable, Xrel:

Xrel = CSV.read(joinpath(data_path,"Xrel.csv"), header=false)

But when I try to do this, Julia produces:

“MethodError: Cannot ‘convert’ an object of type Bool to an object of type String.”

It seems obvious to me that the data type is not boolean.

I’ve checked my paths and opened the CSV without a problem in R - it’s only in Julia that I am having an issue.

I am confused as to why Julia is saying that my data is Boolean when its a matrix of numbers? How can I resolve this to read in my CSV file?

Thanks!

Welcome to this fine community, @billingsham !

Which version are you using, can you post:

julia> versioninfo()
Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: AMD Ryzen 9 3900X 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, znver2)

and

(@v1.5) pkg> st
Status `C:\Users\oheil\.julia\environments\v1.5\Project.toml`
  ...
  [336ed68f] CSV v0.8.3
  ...

There has been similar questions here with CSV and I suspect that people are trying outdated examples from some websites. The CSV API has changed quite a bit.

Hey! Thanks for your response.

I`m running:

Julia Version 1.5.3
Commit 788b2c77c1 (2020-11-09 13:37 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel® Core™ i5-5250U CP
U @ 1.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)
Environment:
JULIA_NUM_THREADS = 2

and

Status ~/Library/Mobile Documents/com~apple~CloudDocs/Academics/Postgraduate/Year 2/Thesis/Data/Replication files for Altavila 2018/code/jcode/Project.toml
[336ed68f] CSV v0.5.2

I’ve seen a lot of discussion regarding CSVs, but nothing that might be of help.
Any clues?

Can you try:

Xrel = CSV.File(joinpath(data_path,"Xrel.csv"); header = false)

(EDIT: false instead of 0)

1 Like

Your version of CSV is quite old, try to ] add CSV@0.8

1 Like