include csv2mat.inp # standard case open data4-1.gdt --quiet store test.csv X = csv2mat("test.csv") print X X = mread("test.csv") print X # malformed s = sprintf("a;b;c\n1;2;3\n5;6\n7;8;9;1000\n") outfile test.csv --write print s end outfile X = csv2mat("test.csv") print X printf "malformed input, not handed by mread()\n\n" # weird delimiter, and NAs interspersed s = sprintf("1!2!3\n!5!6\n7!NA!9\n") outfile test.csv --write print s end outfile X = csv2mat("test.csv", "!") print X set csv_delim "!" X = mread("test.csv") print X set csv_delim comma # from the web X = csv2mat("https://app.quadstat.net/system/files/datasets/dataset-65863.csv") print X X = mread("https://app.quadstat.net/system/files/datasets/dataset-65863.csv") print X # simple OK case, without column names s = sprintf("1;2;3\n;5;6\n7;NA;9\n") outfile test.csv --write print s end outfile X = csv2mat("test.csv") print X X = mread("test.csv") print X # simple case, but with a missing colname s = sprintf("a;;c\n1;2;3\n;5;6\n7;NA;9\n") outfile test.csv --write print s end outfile X = csv2mat("test.csv") print X X = mread("test.csv") print X