trying to learn some basics of IO in julia. All I want for now is to read
tabular part of following file in two separate arrays:
# gamma-ray energies and probability
# of emission for 56Ni from
# Ambwani & Sutherland (1988) Table#1
# E[Mev] f
0.158 1.00
0.270 0.36
0.480 0.36
0.750 0.50
0.812 0.87
1.562 0.14
After skimming the manual this is what I've come up with:
ign = 4 # how many lines to ignore from top
lines=String[]
f=open(fname,"r") do f
for line in eachline(f) push!(lines,line) end
end
col1 = zeros(length(lines)-ign)
col2 = zeros(length(lines)-ign)
for i=(ign+1):length(lines)
(col1[i-ign],col2[i-ign])=readdlm(IOBuffer(lines[i]),Float64)
end
Obviously I don't like what I have at all: (1) what is a proper way to
convert the String into a Float64 type? IOBuffer works but terribly slow.
(2) how do I create the script such that I don't specify how many lines to
ignore from top (ign not manually defined)?
BTW, is there an equivalent to IDL's "readcol.pro"
<http://idlastro.gsfc.nasa.gov/ftp/pro/misc/readcol.pro> in Julia? using
this procedure in IDL it is just:
readcol,fname,col1,col2,format='d,d'
thanks,