@@ -109,7 +109,7 @@ function dlm_fill{T}(cells::Array{T,2}, offsets::Array{Int,2}, sbuff::String, au
109
109
110
110
if T <: Char
111
111
(length (sval) != 1 ) && error (" file entry \" $(sval) \" is not a Char" )
112
- cells[cell_row,col] = sval
112
+ cells[cell_row,col] = next ( sval, 1 )[ 1 ]
113
113
elseif T <: Number
114
114
if (float64_isvalid (sval, tmp64))
115
115
cells[cell_row,col] = tmp64[1 ]
132
132
133
133
134
134
function dlm_offsets (sbuff:: UTF8String , dlm, eol, offsets:: Array{Int,2} )
135
+ isascii (dlm) && isascii (eol) && (return dlm_offsets (sbuff. data, uint8 (dlm), uint8 (eol), offsets))
136
+
135
137
col = 0
136
138
row = 1
137
139
maxrow,maxcol = size (offsets)
@@ -145,10 +147,9 @@ function dlm_offsets(sbuff::UTF8String, dlm, eol, offsets::Array{Int,2})
145
147
(val == eol) && (row += 1 ; col = 0 )
146
148
end
147
149
end
148
- function dlm_offsets (sbuff:: ASCIIString , dlmc, eolc, offsets:: Array{Int,2} )
149
- dbuff = sbuff. data
150
- dlm = uint8 (dlmc)
151
- eol = uint8 (eolc)
150
+
151
+ dlm_offsets (sbuff:: ASCIIString , dlmc, eolc, offsets:: Array{Int,2} ) = dlm_offsets (sbuff. data, uint8 (dlmc), uint8 (eolc), offsets)
152
+ function dlm_offsets (dbuff:: Vector{Uint8} , dlm:: Uint8 , eol:: Uint8 , offsets:: Array{Int,2} )
152
153
col = 0
153
154
row = 1
154
155
maxrow,maxcol = size (offsets)
@@ -162,8 +163,9 @@ function dlm_offsets(sbuff::ASCIIString, dlmc, eolc, offsets::Array{Int,2})
162
163
end
163
164
end
164
165
165
- dlm_dims (s:: ASCIIString , eol, dlm) = dlm_dims (s. data, uint8 (eol), uint8 (dlm))
166
- function dlm_dims (dbuff, eol, dlm)
166
+ dlm_dims (s:: ASCIIString , eol:: Char , dlm:: Char ) = dlm_dims (s. data, uint8 (eol), uint8 (dlm))
167
+ function dlm_dims {T,D} (dbuff:: T , eol:: D , dlm:: D )
168
+ isa (dbuff, UTF8String) && isascii (eol) && isascii (dlm) && (return dlm_dims (dbuff. data, uint8 (eol), uint8 (dlm)))
167
169
ncols = nrows = col = 0
168
170
try
169
171
for val in dbuff
@@ -184,22 +186,19 @@ readcsv(io; opts...) = readdlm(io, ','; opts...)
184
186
readcsv (io, T:: Type ; opts... ) = readdlm (io, ' ,' , T; opts... )
185
187
186
188
# todo: keyword argument for # of digits to print
189
+ writedlm_cell {T<:FloatingPoint} (io:: IO , elt:: T ) = print_shortest (io, elt)
190
+ writedlm_cell (io:: IO , elt) = print (io, elt)
187
191
function writedlm (io:: IO , a:: Matrix , dlm:: Char )
192
+ pb = PipeBuffer ()
188
193
nr, nc = size (a)
189
194
for i = 1 : nr
190
195
for j = 1 : nc
191
- elt = a[i,j]
192
- if isa (elt,FloatingPoint)
193
- print_shortest (io, elt)
194
- else
195
- print (io, elt)
196
- end
197
- if j < nc
198
- write (io, dlm)
199
- end
196
+ writedlm_cell (pb, a[i,j])
197
+ write (pb, (j == nc) ? ' \n ' : dlm)
200
198
end
201
- write (io, ' \n ' )
199
+ ( nb_available (pb) > ( 16 * 1024 )) && write (io, takebuf_array (pb) )
202
200
end
201
+ write (io, takebuf_array (pb))
203
202
nothing
204
203
end
205
204
0 commit comments