Skip to content

Commit 16cfe4d

Browse files
committed
Move datafmt docs out, update them a bit
1 parent ec15da7 commit 16cfe4d

File tree

3 files changed

+87
-92
lines changed

3 files changed

+87
-92
lines changed

base/datafmt.jl

+82
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,79 @@ function countlines(io::IO, eol::Char='\n')
3030
nl
3131
end
3232

33+
"""
34+
readdlm(source, T::Type; options...)
35+
36+
The columns are assumed to be separated by one or more whitespaces. The end of line
37+
delimiter is taken as `\\n`.
38+
"""
3339
readdlm(input, T::Type; opts...) = readdlm(input, invalid_dlm(Char), T, '\n'; opts...)
40+
41+
"""
42+
readdlm(source, delim::Char, T::Type; options...)
43+
44+
The end of line delimiter is taken as `\\n`.
45+
"""
3446
readdlm(input, dlm::Char, T::Type; opts...) = readdlm(input, dlm, T, '\n'; opts...)
3547

48+
"""
49+
readdlm(source; options...)
50+
51+
The columns are assumed to be separated by one or more whitespaces. The end of line
52+
delimiter is taken as `\\n`. If all data is numeric, the result will be a numeric array. If
53+
some elements cannot be parsed as numbers, a heterogeneous array of numbers and strings
54+
is returned.
55+
"""
3656
readdlm(input; opts...) = readdlm(input, invalid_dlm(Char), '\n'; opts...)
57+
58+
"""
59+
readdlm(source, delim::Char; options...)
60+
61+
The end of line delimiter is taken as `\\n`. If all data is numeric, the result will be a
62+
numeric array. If some elements cannot be parsed as numbers, a heterogeneous array of
63+
numbers and strings is returned.
64+
"""
3765
readdlm(input, dlm::Char; opts...) = readdlm(input, dlm, '\n'; opts...)
3866

67+
"""
68+
readdlm(source, delim::Char, eol::Char; options...)
69+
70+
If all data is numeric, the result will be a numeric array. If some elements cannot be
71+
parsed as numbers, a heterogeneous array of numbers and strings is returned.
72+
"""
3973
readdlm(input, dlm::Char, eol::Char; opts...) =
4074
readdlm_auto(input, dlm, Float64, eol, true; opts...)
75+
76+
"""
77+
readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, quotes=true, dims, comments=true, comment_char='#')
78+
79+
Read a matrix from the source where each line (separated by `eol`) gives one row, with
80+
elements separated by the given delimiter. The source can be a text file, stream or byte
81+
array. Memory mapped files can be used by passing the byte array representation of the
82+
mapped segment as source.
83+
84+
If `T` is a numeric type, the result is an array of that type, with any non-numeric elements
85+
as `NaN` for floating-point types, or zero. Other useful values of `T` include
86+
`String`, `AbstractString`, and `Any`.
87+
88+
If `header` is `true`, the first row of data will be read as header and the tuple
89+
`(data_cells, header_cells)` is returned instead of only `data_cells`.
90+
91+
Specifying `skipstart` will ignore the corresponding number of initial lines from the input.
92+
93+
If `skipblanks` is `true`, blank lines in the input will be ignored.
94+
95+
If `use_mmap` is `true`, the file specified by `source` is memory mapped for potential
96+
speedups. Default is `true` except on Windows. On Windows, you may want to specify `true` if
97+
the file is large, and is only read once and not written to.
98+
99+
If `quotes` is `true`, columns enclosed within double-quote (\") characters are allowed to
100+
contain new lines and column delimiters. Double-quote characters within a quoted field must
101+
be escaped with another double-quote. Specifying `dims` as a tuple of the expected rows and
102+
columns (including header, if any) may speed up reading of large files. If `comments` is
103+
`true`, lines beginning with `comment_char` and text following `comment_char` in any line
104+
are ignored.
105+
"""
41106
readdlm(input, dlm::Char, T::Type, eol::Char; opts...) =
42107
readdlm_auto(input, dlm, T, eol, false; opts...)
43108

@@ -624,7 +689,24 @@ function writedlm(fname::AbstractString, a, dlm; opts...)
624689
end
625690
end
626691

692+
"""
693+
writedlm(f, A, dl='\\t'; opts)
694+
695+
Write `A` (a vector, matrix or an iterable collection of iterable rows) as text to `f`
696+
(either a filename string or an `IO` stream) using the given delimiter `delim` (which
697+
defaults to tab, but can be any printable Julia object, typically a `Char` or
698+
`AbstractString`).
699+
700+
For example, two vectors `x` and `y` of the same length can be written as two columns of
701+
tab-delimited text to `f` by either `writedlm(f, [x y])` or by `writedlm(f, zip(x, y))`.
702+
"""
627703
writedlm(io, a; opts...) = writedlm(io, a, '\t'; opts...)
704+
705+
"""
706+
writecsv(filename, A; opts)
707+
708+
Equivalent to `writedlm` with `delim` set to comma.
709+
"""
628710
writecsv(io, a; opts...) = writedlm(io, a, ','; opts...)
629711

630712
show(io::IO, ::MIME"text/csv", a) = writedlm(io, a, ',')

base/docs/helpdb/Base.jl

+3-90
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,11 @@ Raises a `SystemError` for `errno` with the descriptive string `sysfunc` if `ift
1010
systemerror
1111

1212
"""
13-
writedlm(f, A, delim='\\t')
13+
digamma(x)
1414
15-
Write `A` (a vector, matrix or an iterable collection of iterable rows) as text to `f`
16-
(either a filename string or an `IO` stream) using the given delimiter `delim` (which
17-
defaults to tab, but can be any printable Julia object, typically a `Char` or
18-
`AbstractString`).
19-
20-
For example, two vectors `x` and `y` of the same length can be written as two columns of
21-
tab-delimited text to `f` by either `writedlm(f, [x y])` or by `writedlm(f, zip(x, y))`.
15+
Compute the digamma function of `x` (the logarithmic derivative of `gamma(x)`)
2216
"""
23-
writedlm
17+
digamma
2418

2519
"""
2620
fill!(A, x)
@@ -2236,13 +2230,6 @@ Largest integer less than or equal to `x/y`.
22362230
"""
22372231
fld
22382232

2239-
"""
2240-
writecsv(filename, A)
2241-
2242-
Equivalent to `writedlm` with `delim` set to comma.
2243-
"""
2244-
writecsv
2245-
22462233
"""
22472234
withenv(f::Function, kv::Pair...)
22482235
@@ -2860,80 +2847,6 @@ second variant.
28602847
"""
28612848
popdisplay
28622849

2863-
"""
2864-
readdlm(source, delim::Char, T::Type, eol::Char; header=false, skipstart=0, skipblanks=true, use_mmap, quotes=true, dims, comments=true, comment_char='#')
2865-
2866-
Read a matrix from the source where each line (separated by `eol`) gives one row, with
2867-
elements separated by the given delimiter. The source can be a text file, stream or byte
2868-
array. Memory mapped files can be used by passing the byte array representation of the
2869-
mapped segment as source.
2870-
2871-
If `T` is a numeric type, the result is an array of that type, with any non-numeric elements
2872-
as `NaN` for floating-point types, or zero. Other useful values of `T` include
2873-
`String`, `AbstractString`, and `Any`.
2874-
2875-
If `header` is `true`, the first row of data will be read as header and the tuple
2876-
`(data_cells, header_cells)` is returned instead of only `data_cells`.
2877-
2878-
Specifying `skipstart` will ignore the corresponding number of initial lines from the input.
2879-
2880-
If `skipblanks` is `true`, blank lines in the input will be ignored.
2881-
2882-
If `use_mmap` is `true`, the file specified by `source` is memory mapped for potential
2883-
speedups. Default is `true` except on Windows. On Windows, you may want to specify `true` if
2884-
the file is large, and is only read once and not written to.
2885-
2886-
If `quotes` is `true`, columns enclosed within double-quote (\") characters are allowed to
2887-
contain new lines and column delimiters. Double-quote characters within a quoted field must
2888-
be escaped with another double-quote. Specifying `dims` as a tuple of the expected rows and
2889-
columns (including header, if any) may speed up reading of large files. If `comments` is
2890-
`true`, lines beginning with `comment_char` and text following `comment_char` in any line
2891-
are ignored.
2892-
"""
2893-
readdlm(source, delim, T, eol)
2894-
2895-
"""
2896-
readdlm(source, delim::Char, eol::Char; options...)
2897-
2898-
If all data is numeric, the result will be a numeric array. If some elements cannot be
2899-
parsed as numbers, a heterogeneous array of numbers and strings is returned.
2900-
"""
2901-
readdlm(source, delim::Char, eol::Char)
2902-
2903-
"""
2904-
readdlm(source, delim::Char, T::Type; options...)
2905-
2906-
The end of line delimiter is taken as `\\n`.
2907-
"""
2908-
readdlm(source, delim::Char, T::Type)
2909-
2910-
"""
2911-
readdlm(source, delim::Char; options...)
2912-
2913-
The end of line delimiter is taken as `\\n`. If all data is numeric, the result will be a
2914-
numeric array. If some elements cannot be parsed as numbers, a heterogeneous array of
2915-
numbers and strings is returned.
2916-
"""
2917-
readdlm(source, delim::Char)
2918-
2919-
"""
2920-
readdlm(source, T::Type; options...)
2921-
2922-
The columns are assumed to be separated by one or more whitespaces. The end of line
2923-
delimiter is taken as `\\n`.
2924-
"""
2925-
readdlm(source, T::Type)
2926-
2927-
"""
2928-
readdlm(source; options...)
2929-
2930-
The columns are assumed to be separated by one or more whitespaces. The end of line
2931-
delimiter is taken as `\\n`. If all data is numeric, the result will be a numeric array. If
2932-
some elements cannot be parsed as numbers, a heterogeneous array of numbers and strings
2933-
is returned.
2934-
"""
2935-
readdlm(source)
2936-
29372850
"""
29382851
filesize(path...)
29392852

doc/stdlib/io-network.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ Text I/O
624624
625625
The columns are assumed to be separated by one or more whitespaces. The end of line delimiter is taken as ``\n``\ . If all data is numeric, the result will be a numeric array. If some elements cannot be parsed as numbers, a heterogeneous array of numbers and strings is returned.
626626

627-
.. function:: writedlm(f, A, delim='\\t')
627+
.. function:: writedlm(f, A, dl='\\t'; opts)
628628

629629
.. Docstring generated from Julia source
630630
@@ -638,7 +638,7 @@ Text I/O
638638
639639
Equivalent to ``readdlm`` with ``delim`` set to comma.
640640

641-
.. function:: writecsv(filename, A)
641+
.. function:: writecsv(filename, A; opts)
642642

643643
.. Docstring generated from Julia source
644644

0 commit comments

Comments
 (0)