Skip to content

Commit c811d70

Browse files
committed
updating from master
1 parent 639156b commit c811d70

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

dataframe-csv/build.gradle.kts

+4-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ tasks.withType<Jar> {
138138
}
139139

140140
// modify all publishing tasks to depend on `changeJarTask` so the sources are swapped out with generated sources
141-
tasks.named { it.startsWith("publish") }.configureEach {
142-
dependsOn(processKDocsMain, changeJarTask)
141+
tasks.configureEach {
142+
if (name.startsWith("publish")) {
143+
dependsOn(processKDocsMain, changeJarTask)
144+
}
143145
}
144146

145147
// Exclude the generated/processed sources from the IDE

dataframe-csv/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/io/FastDoubleParser.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import io.deephaven.csv.containers.ByteSlice
44
import io.deephaven.csv.tokenization.Tokenizer.CustomDoubleParser
55
import org.jetbrains.kotlinx.dataframe.api.ParserOptions
66

7+
/**
8+
* Wrapper around [DoubleParser] so we can use it from Deephaven.
9+
*/
710
internal class FastDoubleParser(parserOptions: ParserOptions) : CustomDoubleParser {
811

912
private val doubleParser = DoubleParser(parserOptions)
1013

1114
override fun parse(bs: ByteSlice): Double {
1215
val array = ByteArray(bs.size())
13-
bs.copyTo(array, 0)
14-
16+
try {
17+
bs.copyTo(array, 0)
18+
} catch (e: Exception) {
19+
throw NumberFormatException("Failed to parse double")
20+
}
1521
return doubleParser.parseOrNull(array)
1622
?: throw NumberFormatException("Failed to parse double")
1723
}

dataframe-csv/src/test/kotlin/org/jetbrains/kotlinx/dataframe/io/DelimCsvTsvTests.kt

+25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.kotest.assertions.throwables.shouldNotThrowAny
44
import io.kotest.assertions.throwables.shouldThrow
55
import io.kotest.matchers.nulls.shouldNotBeNull
66
import io.kotest.matchers.shouldBe
7+
import jdk.nashorn.internal.ir.annotations.Ignore
78
import kotlinx.datetime.LocalDate
89
import kotlinx.datetime.LocalDateTime
910
import org.intellij.lang.annotations.Language
@@ -551,6 +552,30 @@ class DelimCsvTsvTests {
551552
df["bodywt"].type() shouldBe typeOf<Double?>()
552553
}
553554

555+
@Ignore
556+
@Test // TODO https://github.com/deephaven/deephaven-csv/issues/212
557+
fun `multiple spaces as delimiter`() {
558+
@Language("csv")
559+
val csv =
560+
"""
561+
NAME STATUS AGE LABELS
562+
argo-events Active 2y77d app.kubernetes.io/instance=argo-events,kubernetes.io/metadata.name=argo-events
563+
argo-workflows Active 2y77d app.kubernetes.io/instance=argo-workflows,kubernetes.io/metadata.name=argo-workflows
564+
argocd Active 5y18d kubernetes.io/metadata.name=argocd
565+
beta Active 4y235d kubernetes.io/metadata.name=beta
566+
""".trimIndent()
567+
val df = DataFrame.readCsvStr(
568+
text = csv,
569+
delimiter = ' ',
570+
parserOptions = DEFAULT_PARSER_OPTIONS.copy(
571+
nullStrings = DEFAULT_NULL_STRINGS - "",
572+
),
573+
ignoreSurroundingSpaces = false,
574+
)
575+
576+
df.print(borders = true, title = true)
577+
}
578+
554579
companion object {
555580
private val simpleCsv = testCsv("testCSV")
556581
private val simpleCsvZip = testResource("testCSV.zip")

0 commit comments

Comments
 (0)