Skip to content

Commit

Permalink
changed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonkmi committed Nov 24, 2019
1 parent 3bc3e59 commit 7cf0f9b
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/scala/org/codecraftlabs/spark/utils/FileUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@ object FileUtil {
def getListOfFiles(dir: String): List[String] = {
val root = new File(dir)

if (root.exists && root.isDirectory) {
getRecursiveListOfFiles(root).map(item => item.getAbsolutePath).filter(item => item.endsWith(".csv") || item.endsWith(".parquet")).toList
} else {
List[String]()
}
if (!(root.exists && root.isDirectory)) List.empty[String] else getRecursiveListOfFiles(root).map(item => item.getAbsolutePath).filter(item => item.endsWith(".csv") || item.endsWith(".parquet")).toList
}

def getRecursiveListOfFiles(dir: File): Array[File] = {
val these = dir.listFiles
these ++ these.filter(_.isDirectory).flatMap(getRecursiveListOfFiles)
}


def buildFilePath(folder: String, fileName: String): String = {
s"$folder" + getDefault.getSeparator + fileName
}
Expand Down

0 comments on commit 7cf0f9b

Please sign in to comment.