简体   繁体   English

尝试将DataFrame写入CSV文件

[英]Trying to write DataFrame to csv file

i am trying to write my DataFrame to CSV file. 我正在尝试将DataFrame写入CSV文件。 I tried this 我试过了

df.write.format("com.databricks.spark.csv").option("header", true)
  .option("codec", "org.apache.hadoop.io.compress.GzipCodec").save("myFile.csv")  

but it gives me the error : 但这给了我错误:

java.lang.UnsupportedOperationException: CSV data source does not support array<struct<columnName:columntype...

if i however show the DataFrame on the console, it prints fine. 但是,如果我在控制台上显示DataFrame,则可以正常打印。 How can i write to a csv or even a text file would do. 我怎样才能写成一个csv甚至一个文本文件。

Thanks!! 谢谢!!

EDIT 编辑

I didn't need to write everything out. 我不需要把所有内容都写出来。 I selected out the rows needed and got it working thanks for the help though! 我选择了需要的行并使其正常运行,但感谢您的帮助!

You dataframe has a complex column (an Array of structs it seems like). 您的数据框具有一个复杂的列(看起来像一个结构数组)。 With csv you can only have simple column types like String, Int, Date, etc, but no arrays or structs. 使用csv,您只能拥有简单的列类型(例如String,Int,Date等),而没有数组或结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM