Reading text data: `readdlm` is deprecated, so how CSV package is used?

Thank you all for your help!

I confirm that stripwhitespace=true removes spaces at the end of the line.

I also confirm that Tables.matrix best fits my needs right now. (I just want to access the elements as df[3, 5].)

So, the final solution is

df = CSV.read( . . . replace \t with ' ' . . . , Tables.matrix; 
  delim=' ', stripwhitespace=true, ignorerepeated=true, comment="#")

So, as @oheil says, it would be nice if multiple characters could be specified as delim. Then, CSV.read() would be as convenient as readdlm() for this kind of tabulated, space-delimited text data files.

I did add a comment to the github issue @oheil mentioned.


[Aside] CSV.jl, as its name suggests, is designed for CSV and CSV-like data files, which aren’t optimized for viewing on the computer screen. I often need to use Excel or a similar application just to view a CSV file.

On the other hand, I often encounter tabulated, text data files, which are designed to be intelligible on the command terminal.

I don’t know how those tab characters entered the data file my colleague gave me, but the file is intelligible by just

$ less thedatafile.txt

on the command terminal.

1 Like