Last active
July 27, 2022 03:26
-
-
Save stella6767/922a6fe7c3cb5313a3cbb1cbbd4fb1be to your computer and use it in GitHub Desktop.
readDataFromCsv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun readDataFromCsv(filePath: String): List<List<String>?> { | |
var csvList: MutableList<List<String>?> = mutableListOf() | |
val csv = java.io.File(filePath) | |
try { | |
BufferedReader(FileReader(csv)).use { br -> | |
var line: String? | |
while (br.readLine().also { line = it } != null) { | |
//println("line $line") | |
val split: List<String>? = line?.split(",") | |
csvList.add(split) | |
} | |
} | |
} catch (e: IOException) { | |
e.printStackTrace() | |
} | |
return csvList | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment