如果我有大量的压缩csv格式的数据,我如何将其组合成一个csv文件(压缩输出与否无关紧要)?你知道吗
我正在把它读入一个spark数据帧,但是我被困在如何连接pyspark数据帧上。你知道吗
下面是我运行循环并希望为每个循环运行附加数据帧的代码:
schema=StructType([])
result = spark.createDataFrame(sc.emptyRDD(), schema)
for day in range(1,31):
day_str = str(day) if day>=10 else "0"+str(day)
print 'Ingesting %s' % day_str
df = spark.read.format("csv").option("header", "false").option("delimiter", "|").option("inferSchema", "true").load("s3a://key/201811%s" % (day_str))
result = result.unionAll(df)
result.write.save("s3a://key/my_result.csv", format='csv')
这给了我错误AnalysisException: u"Union can only be performed on tables with the same number of columns, but the first table has 0 columns and the second table has 1 columns;;\n'Union\n:- LogicalRDD\n+- Relation[_c0#75] csv\n"
。有谁能帮我继续吗?你知道吗
这对我有用:
但是,当我在重新分区的最后一步中尝试将header加载为true时,这种方法是有效的,header存储为一行。我不知道如何添加这些标题作为标题,而不是作为一行。你知道吗
相关问题 更多 >
编程相关推荐