将par数组转换为scala中的数组

时间:2017-01-05 19:52:58

标签: scala-2.10

我们如何将ParArray[(Double, Double, Double, Double, Double)]转换为Array[(Double, Double, Double, Double, Double)]

我必须使用sc.parallelize(Array[(Double,...)])

创建数据框

除了硬编码(如下所示)还有其他方法吗? for(x1 <- 0 until a.length){ new_a(x1)(0) = a(x1)._1 new_a(x1)(1) = a(x1)._2 new_a(x1)(2) = a(x1)._3 new_a(x1)(3) = a(x1)._4 new_a(x1)(4) = a(x1)._5 }

1 个答案:

答案 0 :(得分:1)

请参阅http://docs.scala-lang.org/overviews/parallel-collections/conversions.html#converting-between-sequential-and-parallel-collections

from sys import argv from os.path import exists import sys import os script,fromf,tof=argv inf=open(fromf) if exists(str(inf))==True: indata=inf.read() outf=open(tof,'w') if exists(str(outf))==True: print("Error! Output file exists.") sys.exit() else: outf.write(indata) print("The task is accomplished.") else: print("Error! Input file doesn't exists.")