You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Hafiz Mujadid <ha...@gmail.com> on 2014/12/19 12:13:38 UTC
reading files recursively using spark
Hi experts!
what is efficient way to read all files using spark from directory and its
sub-directories as well.currently i move all files from directory and it
sub-directories into another temporary directory and then read them all
using sc.textFile method. But I want a method so that moving to temporary
directory cost may be saved.
Thanks
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/reading-files-recursively-using-spark-tp20782.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org
Re: reading files recursively using spark
Posted by madhu phatak <ph...@gmail.com>.
Hi,
You can use FileInputformat API of Hadoop and newApiHadoopFile of spark to
get recursion. More on the topic you can refer here
http://stackoverflow.com/questions/8114579/using-fileinputformat-addinputpaths-to-recursively-add-hdfs-path
On Fri, Dec 19, 2014 at 4:50 PM, Sean Owen <so...@cloudera.com> wrote:
>
> How about using the HDFS API to create a list of all the directories
> to read from, and passing them as a comma-joined string to
> sc.textFile?
>
> On Fri, Dec 19, 2014 at 11:13 AM, Hafiz Mujadid
> <ha...@gmail.com> wrote:
> > Hi experts!
> >
> > what is efficient way to read all files using spark from directory and
> its
> > sub-directories as well.currently i move all files from directory and it
> > sub-directories into another temporary directory and then read them all
> > using sc.textFile method. But I want a method so that moving to temporary
> > directory cost may be saved.
> >
> > Thanks
> >
> >
> >
> > --
> > View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/reading-files-recursively-using-spark-tp20782.html
> > Sent from the Apache Spark User List mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> > For additional commands, e-mail: user-help@spark.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> For additional commands, e-mail: user-help@spark.apache.org
>
>
--
Regards,
Madhukara Phatak
http://www.madhukaraphatak.com
Re: reading files recursively using spark
Posted by Sean Owen <so...@cloudera.com>.
How about using the HDFS API to create a list of all the directories
to read from, and passing them as a comma-joined string to
sc.textFile?
On Fri, Dec 19, 2014 at 11:13 AM, Hafiz Mujadid
<ha...@gmail.com> wrote:
> Hi experts!
>
> what is efficient way to read all files using spark from directory and its
> sub-directories as well.currently i move all files from directory and it
> sub-directories into another temporary directory and then read them all
> using sc.textFile method. But I want a method so that moving to temporary
> directory cost may be saved.
>
> Thanks
>
>
>
> --
> View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/reading-files-recursively-using-spark-tp20782.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> For additional commands, e-mail: user-help@spark.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org
Re: reading files recursively using spark
Posted by Hafiz Mujadid <ha...@gmail.com>.
thanks bethesda!
But if we have structure like this
a/b/a.txt
a/c/c.txt
a/d/e/e.txt
then how can we handle this case?
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/reading-files-recursively-using-spark-tp20782p20785.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org
Re: reading files recursively using spark
Posted by bethesda <sw...@mac.com>.
On hdfs I created:
/one/one.txt # contains text "one"
/one/two/two.txt # contains text "two"
Then:
val data = sc.textFile("/one/*")
data.collect
This returned:
Array(one, two)
So the above path designation appears to automatically recurse for you.
--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/reading-files-recursively-using-spark-tp20782p20784.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org