Searching...
viernes, 9 de junio de 2023

Obtener todos los ficheros CSV dentro de un directorio

 def getAllCsvFiles(directory: File): List[File] = {

if (directory.exists() && directory.isDirectory) { val csvFiles = directory.listFiles().flatMap { file => if (file.isFile && file.getName.endsWith(".csv")) { List(file) } else if (file.isDirectory) { getAllCsvFiles(file) } else { List.empty[File] } } csvFiles.toList } else { List.empty[File] } } }

0 comentarios:

Publicar un comentario

Gracias por participar en esta página.

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

 
Back to top!