Skip to content

Commit

Permalink
fix for writedlm with empty columns
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmaykm committed Mar 26, 2014
1 parent e6e3c39 commit eaef4a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/datafmt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ readcsv(io, T::Type; opts...) = readdlm(io, ',', T; opts...)
# todo: keyword argument for # of digits to print
writedlm_cell(io::IO, elt::FloatingPoint, dlm) = print_shortest(io, elt)
function writedlm_cell{T}(io::IO, elt::String, dlm::T)
if ('"' == elt[1]) || ('\n' in elt) || ((T <: Char) ? (dlm in elt) : contains(elt, dlm))
if !isempty(elt) && (('"' == elt[1]) || ('\n' in elt) || ((T <: Char) ? (dlm in elt) : contains(elt, dlm)))
print(io, '"', replace(elt, r"\"", "\"\""), '"')
else
print(io, elt)
Expand Down
6 changes: 6 additions & 0 deletions test/readdlm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ let x = ["abc", "def\"ghi", "jk\nl"], y = [1, ",", "\"quoted\""], io = IOBuffer(
@test readcsv(io) == [x y]
end

let x = ["a" "b"; "d" ""], io = IOBuffer()
writedlm(io, x)
seek(io, 0)
@test readdlm(io) == x
end


# source: https://www.i18nguy.com/unicode/unicode-example-utf8.zip
let i18n_data = ["Origin (English)", "Name (English)", "Origin (Native)", "Name (Native)",
Expand Down

0 comments on commit eaef4a1

Please sign in to comment.