diff options
author | nea <nea@nea.moe> | 2023-03-10 20:48:43 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-03-10 20:48:43 +0100 |
commit | 2f45a494964050ece8724c798a58e577f1a9aeec (patch) | |
tree | ecaf0103bdac89dfdaa6efa3096e33c61af3cb8a /src/main/kotlin/mcprepack/CSVFile.kt | |
parent | d0dd7dafbaccb79f1ecaa574b85dcbb648d35128 (diff) | |
download | mcprepack-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.kt | 8 |
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() + } } |