You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2019/02/08 08:37:00 UTC

[jira] [Commented] (SPARK-26846) Empty Strings in dataframe are written as "" in CSV

    [ https://issues.apache.org/jira/browse/SPARK-26846?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16763412#comment-16763412 ] 

Dongjoon Hyun commented on SPARK-26846:
---------------------------------------

Hi, [~ariyer]. Could you try the option `emptyValue`?
{code}
scala> spark.version
res10: String = 2.4.0
scala> df.write.mode("overwrite").option("emptyValue", "").csv("/tmp/csv")
{code}

{code}
$ cat csv/pa*
8,100,sfd
0,,sfd
8,,asfasd
{code}

> Empty Strings in dataframe are written as "" in CSV
> ---------------------------------------------------
>
>                 Key: SPARK-26846
>                 URL: https://issues.apache.org/jira/browse/SPARK-26846
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.4.0
>            Reporter: Arvind Krishnan Iyer
>            Priority: Major
>
>  
> {code:java}
> import spark.implicits._
> val sc = spark.sparkContext
> val df = Seq((8,"100","sfd"),(0,"","sfd"),(8, null, "asfasd")).toDF("num","str_num","word").toDF().coalesce(1)
> df.write.mode(SaveMode.Overwrite).csv("/Users/arvind.iyer/abcd.csv")
> {code}
> We are writing the contents of this CSV into a DB, and the contents of that column are going in as "". 
> +Output+ 
> 8,100,sfd
>  0,"",sfd
>  8,"",asfasd



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org