A test where readcsv and writecsv fail

testing

#1

Consider the following test. It randomly samples from a bunch of symbols, builds a matrix, writecsvs it, readcsvs it, and then compares the two. It fails with even really small ns.

function genmat(collection, n)
    #randomly collects `n` charachters from String `collection` and fills a 3x2 matrix, saves this matrix to csv file, reads the text of this saved file, and returns both matrices
    c = [i for i in collection]
    x = [join(rand(c, n)) for i = 1:3, j = 1:2]
    writecsv("a.csv", x, quotes = true)
    y = readcsv("a.csv", String, quotes = true)
    return (x, y)
end

collection = """!#¤%"&/()=?*_:;><,.-'§½`'äöåÄÖÅ\\\n\t\b """
n = 1000
x, y = genmat(collection, n)
@assert x == y # this fails with high probabilities even for a really small `n`

maybe this is related.


#2

It would be good to add comments=false, skipblanks=false to writecsv and readcsv options. And the related thread does fix a bug in the implementation when Unicode characters are included, so using a fixed-up 0.6 master branch would be advisable to find additional errors.


#3

Forgot to add, I tested this on the nightly releases here. It might be fine in the more resent versions.


#4

Tested with 0.6.0-pre.alpha.293 (2017-03-28) and with the extra options I mentioned and it worked - three times with n = 1000.


#5

Awesome.
I guess, just because this doesn’t seem to be a feature, but more of a bug of a pretty basic function (read and write csv files), maybe the fix should trickle down to the older versions of Julia as well?