Skip to content

Commit fff717d

Browse files
committed
Update generated sources with recent changes
1 parent 47228e6 commit fff717d

File tree

2 files changed

+20
-6
lines changed
  • core/generated-sources/src
    • main/kotlin/org/jetbrains/kotlinx/dataframe/io
    • test/kotlin/org/jetbrains/kotlinx/dataframe/io

2 files changed

+20
-6
lines changed

core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/io/csv.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public class CSV(private val delimiter: Char = ',') : SupportedDataFrameFormat {
5757
}
5858

5959
public enum class CSVType(public val format: CSVFormat) {
60-
DEFAULT(CSVFormat.DEFAULT.withAllowMissingColumnNames().withIgnoreSurroundingSpaces()),
61-
TDF(CSVFormat.TDF.withAllowMissingColumnNames())
60+
DEFAULT(CSVFormat.DEFAULT.builder().setAllowMissingColumnNames(true).setIgnoreSurroundingSpaces(true).build()),
61+
TDF(CSVFormat.TDF.builder().setAllowMissingColumnNames(true).build())
6262
}
6363

6464
private val defaultCharset = Charsets.UTF_8
@@ -73,11 +73,15 @@ internal fun isCompressed(url: URL) = isCompressed(url.path)
7373
@Interpretable("ReadDelimStr")
7474
public fun DataFrame.Companion.readDelimStr(
7575
text: String,
76+
delimiter: Char = ',',
7677
colTypes: Map<String, ColType> = mapOf(),
7778
skipLines: Int = 0,
7879
readLines: Int? = null,
7980
): DataFrame<*> =
80-
StringReader(text).use { readDelim(it, CSVType.DEFAULT.format.withHeader(), colTypes, skipLines, readLines) }
81+
StringReader(text).use {
82+
val format = CSVType.DEFAULT.format.builder().setHeader().setDelimiter(delimiter).build()
83+
readDelim(it, format, colTypes, skipLines, readLines)
84+
}
8185

8286
public fun DataFrame.Companion.read(
8387
fileOrUrl: String,
@@ -212,7 +216,7 @@ public fun asURL(fileOrUrl: String): URL = (
212216
).toURL()
213217

214218
private fun getFormat(type: CSVType, delimiter: Char, header: List<String>, duplicate: Boolean): CSVFormat =
215-
type.format.withDelimiter(delimiter).withHeader(*header.toTypedArray()).withAllowDuplicateHeaderNames(duplicate)
219+
type.format.builder().setDelimiter(delimiter).setHeader(*header.toTypedArray()).setAllowMissingColumnNames(duplicate).build()
216220

217221
public fun DataFrame.Companion.readDelim(
218222
inStream: InputStream,
@@ -268,7 +272,7 @@ public fun ColType.toType(): KClass<out Any> = when (this) {
268272

269273
public fun DataFrame.Companion.readDelim(
270274
reader: Reader,
271-
format: CSVFormat = CSVFormat.DEFAULT.withHeader(),
275+
format: CSVFormat = CSVFormat.DEFAULT.builder().setHeader().build(),
272276
colTypes: Map<String, ColType> = mapOf(),
273277
skipLines: Int = 0,
274278
readLines: Int? = null,

core/generated-sources/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/CsvTests.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class CsvTests {
242242
)
243243
df.writeCSV(
244244
"src/test/resources/without_header.csv",
245-
CSVFormat.DEFAULT.withSkipHeaderRecord(),
245+
CSVFormat.DEFAULT.builder().setSkipHeaderRecord(true).build(),
246246
)
247247
val producedFile = File("src/test/resources/without_header.csv")
248248
producedFile.exists() shouldBe true
@@ -258,6 +258,16 @@ class CsvTests {
258258
df shouldBe DataFrame.readCSV("../data/jetbrains repositories.csv")
259259
}
260260

261+
@Test
262+
fun `readDelimStr delimiter`() {
263+
val tsv = """
264+
a b c
265+
1 2 3
266+
""".trimIndent()
267+
val df = DataFrame.readDelimStr(tsv, '\t')
268+
df shouldBe dataFrameOf("a", "b", "c")(1, 2, 3)
269+
}
270+
261271
companion object {
262272
private val simpleCsv = testCsv("testCSV")
263273
private val csvWithFrenchLocale = testCsv("testCSVwithFrenchLocale")

0 commit comments

Comments
 (0)