writecsv

writecsv(filename, A)

Equivalent to writedlm with delim set to comma.

Examples

julia> using DelimitedFiles

julia> writecsv("data.csv", [1 2 3; 4 5 6; 7 8 9])

This example writes a 3x3 matrix to a CSV file named "data.csv". The elements of the matrix are separated by commas.

julia> using DelimitedFiles

julia> A = ["apple" "banana" "orange"; "dog" "cat" "mouse"]
julia> writecsv("fruits.csv", A)

In this example, a 2x3 matrix of strings is written to a CSV file named "fruits.csv". The elements of the matrix are separated by commas.

Common mistake example:

julia> using DelimitedFiles

julia> writecsv(["1", "2", "3"], "data.csv")
ERROR: MethodError: no method matching writecsv(::Array{String,1}, ::String)

In this example, the arguments provided to writecsv are reversed. The file path should be passed as the first argument, followed by the data to be written.

See Also

abspath, basename, chmod, countlines, cp, ctime, dirname, download, evalfile, expanduser, fdio, filemode, filesize, functionloc, gperm, homedir, include_string, isabspath, isblockdev, ischardev, isdir, isdirpath, isexecutable, isfifo, isfile, islink, ismount, ispath, isreadable, issetgid, issetuid, issticky, iswritable, joinpath, less, lstat, mkdir, mkpath, mktemp, mktempdir, mtime, mv, normpath, operm, poll_fd, poll_file, readall, readcsv, readdir, readdlm, readlines, readlink, realpath, relpath, rm, splitdir, splitdrive, splitext, stat, symlink, tempdir, tempname, touch, truncate, uperm, watch_file, writecsv,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: