aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/mcprepack/CSVFile.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-03-10 20:48:43 +0100
committernea <nea@nea.moe>2023-03-10 20:48:43 +0100
commit2f45a494964050ece8724c798a58e577f1a9aeec (patch)
treeecaf0103bdac89dfdaa6efa3096e33c61af3cb8a /src/main/kotlin/mcprepack/CSVFile.kt
parentd0dd7dafbaccb79f1ecaa574b85dcbb648d35128 (diff)
downloadmcprepack-2f45a494964050ece8724c798a58e577f1a9aeec.tar.gz
mcprepack-2f45a494964050ece8724c798a58e577f1a9aeec.tar.bz2
mcprepack-2f45a494964050ece8724c798a58e577f1a9aeec.zip
Better csv reading and comments
Diffstat (limited to 'src/main/kotlin/mcprepack/CSVFile.kt')
-rw-r--r--src/main/kotlin/mcprepack/CSVFile.kt8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/main/kotlin/mcprepack/CSVFile.kt b/src/main/kotlin/mcprepack/CSVFile.kt
index 1ddc03f..b2bcfaa 100644
--- a/src/main/kotlin/mcprepack/CSVFile.kt
+++ b/src/main/kotlin/mcprepack/CSVFile.kt
@@ -3,4 +3,12 @@ package mcprepack
data class CSVFile(val headers: List<String>, val entries: List<List<String>>) {
val map = entries.map { headers.zip(it).toMap() }
val indexedBySearge = map.associateBy { it["searge"] }
+ val indexedByParamName = map.groupBy {
+ val match = it["param"]?.let { paramRegex.matchEntire(it) } ?: return@groupBy null
+ match.groupValues[1].toInt()
+ }
+
+ companion object {
+ val paramRegex = "p_([0-9]+)_([0-9]+)_.*".toRegex()
+ }
}