简体   繁体   English

Pyspark写入文件不存在

[英]Pyspark write in file doesn't not exist

I try to write in file in pyspark but I have an error, the file doesn't exist.我尝试在 pyspark 中写入文件,但出现错误,该文件不存在。 I'm new in pyspark.我是 pyspark 的新手。

I have this code for write:我有这个写代码:

result.repartition(1).write.partitionBy('client', 'payload_type').json(OUTPUT_PATH, mode='append')

Is it possible to add a parameter to force to create folder/file if doesn't exist ?如果不存在,是否可以添加参数以强制创建文件夹/文件?

I make a mistake, the error is not at the line of the post but this:我犯了一个错误,错误不在帖子的那一行,而是这个:

existing_data = spark.read.json(OUTPUT_PATH)

with:和:

OUTPUT_PATH = f"s3a://{BUCKET_DEST}/{SOURCE}/"

At the first execution, both folder doesn't exist, can I force create it if no exist on the read?在第一次执行时,两个文件夹都不存在,如果读取中不存在,我可以强制创建它吗?

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

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