Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

readcsv fails to read # character in Julia

Tags:

julia

I've been using asd=readcsv(filename) to read a csv file in Julia.

The first row of the csv file contains strings which describe the column contents; the rest of the data is a mix of integers and floats. readcsv reads the numbers just fine, but only reads the first 4+1/2 string entries.

After that, it renders "". If I ask the REPL to display asd[1,:], it tells me it is 1x65 Array{Any,2}.

The fifth column in the first row of the csv file (this seems to be the entry it chokes on) is APP #1 bias voltage [V]; but asd[1,5] is just APP . So it looks to me as though readcsv has choked on the "#" character.

I tried using "quotes=false" keyword in readcsv, but it didn't help.

I used to use xlsread in Matlab and it worked fine. Has anybody out there seen this sort of thing before?

like image 782
JuliaNewbie Avatar asked May 04 '16 17:05

JuliaNewbie


1 Answers

The comment character in Julia is #, and this applies when reading files from delimited text files.

But luckily, the readcsv() and readdlm() functions have an optional argument to help in these situations.

You should try readcsv(filename; comment_char = '/').

Of course, the example above assumes that you don't have any / characters in your first line. If you do, then you'll have to change that / above to something else.

like image 193
paulstey Avatar answered Sep 18 '22 20:09

paulstey