Spark Scala list folders in directory

前端 未结 9 2458
北恋
北恋 2020-12-05 09:41

I want to list all folders within a hdfs directory using Scala/Spark. In Hadoop I can do this by using the command: hadoop fs -ls hdfs://sandbox.hortonworks.com/demo/<

9条回答
  •  孤城傲影
    2020-12-05 10:13

    Azure Blog Storage is mapped to a HDFS location, so all the Hadoop Operations

    On Azure Portal, go to Storage Account, you will find following details:

    • Storage account

    • Key -

    • Container -

    • Path pattern – /users/accountsdata/

    • Date format – yyyy-mm-dd

    • Event serialization format – json

    • Format – line separated

    Path Pattern here is the HDFS path, you can login/putty to the Hadoop Edge Node and do:

    hadoop fs -ls /users/accountsdata 
    

    Above command will list all the files. In Scala you can use

    import scala.sys.process._ 
    
    val lsResult = Seq("hadoop","fs","-ls","/users/accountsdata/").!!
    

提交回复
热议问题