Hi, upendra. It will be easier to use DataFrame to read/save csv file with header, if you'd like.
On Tue, Jun 6, 2017 at 5:15 AM, upendra 1991 <upendra1...@yahoo.com.invalid> wrote: > I am reading a CSV(file has headers header 1st,header2) and generating > rdd, > After few transformations I create an rdd and finally write it to a txt > file. > > What's the best way to add the header from source file, into rdd and have > it available as header into new file I.e, when I transform the rdd into > textfile using saveAsTexFile("newfile") the header 1, header 2 shall be > available. > > > Thanks, > Upendra >