aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/mcprepack/CSVFile.kt
blob: b2bcfaa616b0ae8984105690c85f41482a8f82e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()
    }
}