You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by go canal <go...@yahoo.com.INVALID> on 2015/08/15 04:50:19 UTC
How to save a string to a text file ?
Hello again,online resources have sample code for writing RDD to a file, but I have a simple string, how to save to a text file ? (my data is a DenseMatrix actually)
appreciate any help ! thanks, canal
Re: How to save a string to a text file ?
Posted by go canal <go...@yahoo.com.INVALID>.
thank you very much. just a quick question - I try to save string in this way but the file is always empty:
val file = Path ("sample data/ZN_SPARK.OUT").createFile(true) file.bufferedWriter().write(im.toString()) file.bufferedWriter().flush() file.bufferedWriter().close()
anything wrong ? thanks, canal
On Saturday, August 15, 2015 11:21 AM, Brandon White <bw...@gmail.com> wrote:
Convert it to a rdd then save the rdd to a file
val str = "dank memes"sc.parallelize(List(str)).saveAsTextFile("str.txt")
On Fri, Aug 14, 2015 at 7:50 PM, go canal <go...@yahoo.com.invalid> wrote:
Hello again,online resources have sample code for writing RDD to a file, but I have a simple string, how to save to a text file ? (my data is a DenseMatrix actually)
appreciate any help ! thanks, canal
Re: How to save a string to a text file ?
Posted by Brandon White <bw...@gmail.com>.
Convert it to a rdd then save the rdd to a file
val str = "dank memes"
sc.parallelize(List(str)).saveAsTextFile("str.txt")
On Fri, Aug 14, 2015 at 7:50 PM, go canal <go...@yahoo.com.invalid> wrote:
> Hello again,
> online resources have sample code for writing RDD to a file, but I have a
> simple string, how to save to a text file ? (my data is a DenseMatrix
> actually)
>
> appreciate any help !
>
> thanks, canal
>