Skip to content

Instantly share code, notes, and snippets.

@JeffBezanson
Created March 7, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffBezanson/83fb1d79deefa2316067 to your computer and use it in GitHub Desktop.
Save JeffBezanson/83fb1d79deefa2316067 to your computer and use it in GitHub Desktop.
function rd(f)
nr = countlines(f)::Int
fh = open(f)
nc = length(split(readline(fh),','))
seekstart(fh)
d = Array(Float64, nr, nc)
temp = [0.0]
for i = 1:nr
l = readline(fh)::ASCIIString
idx = 1
for j = 1:nc
nxt = search(l, ',', idx)
if nxt == 0; nxt = endof(l); end
ccall(:jl_substrtod, Int32, (Ptr{UInt8},Csize_t,Cint,Ptr{Float64}),
l, idx-1, nxt-idx, temp)
d[i,j] = temp[1]
idx = nxt+1
end
end
d
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment