File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -206,21 +206,15 @@ internal fun DataFrame.Companion.read(
206
206
formats : List <SupportedDataFrameFormat > = supportedFormats.filterIsInstance<SupportedDataFrameFormat >(),
207
207
): ReadAnyFrame {
208
208
if (format != null ) return format to format.readDataFrame(stream, header = header)
209
- val input = NotCloseableStream (if (stream.markSupported()) stream else BufferedInputStream (stream))
210
- try {
211
- val readLimit = 10000
212
- input.mark(readLimit)
213
-
209
+ stream.use { input ->
210
+ val byteArray = input.readBytes() // read 8192 bytes
214
211
formats.sortedBy { it.testOrder }.forEach {
215
212
try {
216
- input.reset()
217
- return it to it.readDataFrame(input, header = header)
218
- } catch (e: Exception ) {
213
+ return it to it.readDataFrame(byteArray.inputStream(), header = header)
214
+ } catch (_: Exception ) {
219
215
}
220
216
}
221
217
throw IllegalArgumentException (" Unknown stream format" )
222
- } finally {
223
- input.doClose()
224
218
}
225
219
}
226
220
You can’t perform that action at this time.
0 commit comments