在這里,df 是我們的資料幀,我們在其中有我們的輸出,因為我正在使用 dataframewriter 將整個輸出寫入目錄,但是所有資料都被磁區,如下所述..
$ hdfs dfs -ls /path to hdfs directory..
Found 4 items
-rw-r--r-- 3 xxxxxx xxxxxxx 0 2022-04-28 23:19 path to hdfs directory../_SUCCESS
-rw-r--r-- 3 xxxxxx xxxxxx 238 2022-04-28 23:19 path to hdfs directory../part-00000-4bc48c17-5c85-44be-bf34-3645d2b2e085-c000.csv
-rw-r--r-- 3 xxxxxxx xxxxxxx 6204498 2022-04-28 23:19 path to hdfs directory../part-00043-4bc48c17-5c85-44be-bf34-3645d2b2e085-c000.csv
-rw-r--r-- 3 xxxxxxx xxxxxxx 5875627 2022-04-28 23:19 path to hdfs directory../part-00191-4bc48c17-5c85-44be-bf34-3645d2b2e085-c000.csv
我希望將所有資料放入一個 CSV 檔案中,代碼中是否還有其他選項.. 下面
df.write.mode("overwrite").csv('path to hdfs directory', header = True, sep = ',')
資料在df中大約有55k行。
uj5u.com熱心網友回復:
您可以coalesce(1)用來制作單個 CSV 檔案
df.coalesce(1).write.mode("overwrite").csv('path to hdfs directory', header = True, sep = ',')
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/467274.html
標籤:数据框 CSV pyspark apache-spark-sql 高清晰度电视
上一篇:XSLT模板回圈記錄
