readall(filename::AbstractString)
readall(filename::AbstractString)
Open filename
, read the entire contents as a string, then close the file. Equivalent to open(readall, filename)
.
Examples
julia> a=readall(`echo demo`)
print(a)
"demo\n"
julia> a=readall(`echo hello`)
"hello\n"
julia> (chomp(a)) == "hello"
true
Reading a text file that says hello world
julia> cd("C:\\temp\\julia");
julia> f = open("hello.txt");
julia> s = readall(f);
julia> s
"hello world!"
Reading a CSV File and splitting it
julia> file = open("data.csv");
julia> strings = readall(file);
julia> data = split(strings, "\r\n");
julia> data
4-element Array{SubString{ASCIIString},1}:
"country,population,age"
"America,200,10"
"Japan,20,11"
"China,3000,22"
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.