cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

get a "Py4JJavaError: An error occurred while calling o5082.csv." when trying to save to csv file.

laus
New Contributor III

Hi,

I'm trying to save a dataframe to csv with the code below:

output.coalesce(1).write.mode('overwrite').option('header', 'true').csv(tmp_file_path) 

But it get "Py4JJavaError: An error occurred while calling o5082.csv." error.

Any idea how to solve it?

Screenshot 2022-03-31 at 17.33.13 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Laura Blancarteโ€‹ ,

What format is your "output" dataframe? Have you try to run something like this? output.coalesce(1).write.option("header","true").format("csv").save("path_to_location")

View solution in original post

5 REPLIES 5

Kaniz
Community Manager
Community Manager

Hi @Laura Blancarteโ€‹ , Looks like you want to save your dataframe as CSV. Did you try to download the preview?

Hi @Laura Blancarteโ€‹ ,

What format is your "output" dataframe? Have you try to run something like this? output.coalesce(1).write.option("header","true").format("csv").save("path_to_location")

Hi @Laura Blancarteโ€‹ ,

Just a friendly follow-up. Do you still need help or you were able to find a solution to your question? if my previous response helped you to resolve your questions, please mark it as best.

laus
New Contributor III

Only just seen this but your had used your solution in other scripts and it works!

Awesome @Laura Blancarteโ€‹ . Thank you for the update.