我在HDFS中有一个SequenceFile,我想转换成一个数据帧并插入到一个表中。我在转换部分遇到了一些麻烦。
我有这样的代码:
myseqFile = sc.sequenceFile("/user/sequencefile")我得到了以下结构:
(u' 10', u' 10,34,Center,Tatic')我需要获取以下数据帧:
10,10,34,Center,Tatic为此,我尝试使用以下代码:
res=myseqFile .map(lambda x: tuple(x)).map(lambda x: str(x).split(",")).map(lambda x: (x[0],x[1],x[2],x[3],x[4]))但我还是得到了相同的结果:
(u' 10', u' 10,34,Center,Tatic')如何获得所需的输出?
发布于 2020-11-05 06:34:45
可能是这样的:
res=myseqFile .map(lambda x: x[0] + ',' + x[1]).map(lambda x: str(x).split(",")).map(lambda x: (x[0],x[1],x[2],x[3],x[4]))https://stackoverflow.com/questions/64688533
复制相似问题