【发布时间】:2020-11-06 07:08:06
【问题描述】:
我在 hdfs 的一个 hdfs 目录中有多个 csv 文件:
/project/project_csv/file1.csv
/project/project_csv/file2.csv
/project/project_csv/file3.csv
现在,在我的 pyspark 程序中,我想根据文件的数量迭代路径,并且每次都想将数据存储到数据帧中并将数据加载到特定的表中。
Like:
With the first file1.csv read to df and save to table1:
df = spark.read(file1.csv)
df.write.mode('overwrite').format('hive').saveAsTable(data_base.table_name1)
With the second file2.csv read to df and save to table2:
df = spark.read(file2.csv)
df.write.mode('overwrite').format('hive').saveAsTable(data_base.table_name2)
以同样的方式,想要迭代多个文件并将数据保存到不同的表中。
【问题讨论】:
-
您的问题是什么?你已经完成了你想要达到的目标。
标签: python dataframe pyspark hive pyspark-dataframes