File tree Expand file tree Collapse file tree 1 file changed +0
-51
lines changed
backend/service-import/src/jvmMain/kotlin/dev/johnoreilly/confetti/backend/import Expand file tree Collapse file tree 1 file changed +0
-51
lines changed Original file line number Diff line number Diff line change @@ -228,55 +228,4 @@ object DroidconItaly2025 {
228228 error(" CSV file not found. Tried: ${candidates.joinToString()} " )
229229 }
230230
231- // Minimal CSV parser supporting quoted fields with commas and newlines and escaped quotes ""
232- private fun parseCsv (input : String ): List <List <String >> {
233- val rows = mutableListOf<MutableList <String >>()
234- var current = StringBuilder ()
235- var row = mutableListOf<String >()
236- var inQuotes = false
237- var i = 0
238- while (i < input.length) {
239- val ch = input[i]
240- when (ch) {
241- ' "' -> {
242- if (inQuotes) {
243- if (i + 1 < input.length && input[i + 1 ] == ' "' ) {
244- // Escaped quote
245- current.append(' "' )
246- i++
247- } else {
248- inQuotes = false
249- }
250- } else {
251- inQuotes = true
252- }
253- }
254- ' ,' -> {
255- if (inQuotes) {
256- current.append(ch)
257- } else {
258- row.add(current.toString())
259- current = StringBuilder ()
260- }
261- }
262- ' \r ' -> { /* ignore CR; handle on LF */ }
263- ' \n ' -> {
264- if (inQuotes) {
265- current.append(' \n ' )
266- } else {
267- row.add(current.toString())
268- rows.add(row)
269- row = mutableListOf ()
270- current = StringBuilder ()
271- }
272- }
273- else -> current.append(ch)
274- }
275- i++
276- }
277- // Append last field
278- row.add(current.toString())
279- rows.add(row)
280- return rows
281- }
282231}
You can’t perform that action at this time.
0 commit comments