Skip to content

Commit

Permalink
dlmread: accept multiple consecutive eols
Browse files Browse the repository at this point in the history
  • Loading branch information
nolta committed Jun 2, 2012
1 parent 861cf69 commit 2eb2493
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions base/datafmt.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
## file formats ##

function _jl_dlm_readrow(io, dlm, eol)
row = split(readuntil(io, eol), dlm, true)
row[end] = chomp(row[end])
row
function _jl_dlm_readrow(io::IO, dlm::Char, eol::Char)
row_string = readuntil(io, eol)
while row_string == string(eol)
row_string = readuntil(io, eol)
end
if ends_with(row_string, eol)
row_string = chop(row_string)
end
split(row_string, dlm, true)
end

# all strings
Expand Down Expand Up @@ -91,21 +96,21 @@ function countlines(io::IOStream, eol::Char)
end
a = Array(Uint8, 8192)
nl = 0
preceded_by_eol = true
while !eof(io)
fill!(a, uint8(eol)+1) # fill with byte we're not looking for
fill!(a, uint8(eol))
try
read(io, a)
end
for i=1:length(a)
if a[i] == eol
preceded_by_eol = true
elseif preceded_by_eol
preceded_by_eol = false
nl+=1
end
end
end
skip(io,-1)
if read(io,Uint8) != eol
nl+=1
end
nl
end

Expand Down

0 comments on commit 2eb2493

Please sign in to comment.