<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Spark Read CSV doesn't preserve the double quotes while reading! in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27087#M18987</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;When I tried with &lt;PRE&gt;&lt;CODE&gt;.option("quote","")&lt;/CODE&gt;&lt;/PRE&gt; and .option("quote","\u0000") the company_name column values got splitted into next column like below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;+----------+---------+-------------------------+---------------------+
|first_name|last_name|company_name             |address              |
+----------+---------+-------------------------+---------------------+
|James     |Butt     |"Benton                  | John B Jr"          |
|Josephine |Darakjy  |"Chanay                  | Jeffrey A Esq"      |
|Art       |Venere   |"Chemel                  | James L Cpa"        |
|Lenna     |Paprocki |Feltz Printing Service   |639 Main St          |
|Donette   |Foller   |Printing Dimensions      |34 Center St         |
|Simona    |Morasca  |"Chapman                 | Ross E Esq"         |
+----------+---------+-------------------------+---------------------+&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Aug 2020 16:02:06 GMT</pubDate>
    <dc:creator>DineshKumar</dc:creator>
    <dc:date>2020-08-25T16:02:06Z</dc:date>
    <item>
      <title>Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27086#M18986</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt; Hi , I am trying to read a csv file with one column has double quotes like below. &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;James,Butt,"Benton, John B Jr",6649 N Blue Gum St
Josephine,Darakjy,"Chanay, Jeffrey A Esq",4 B Blue Ridge Blvd
Art,Venere,"Chemel, James L Cpa",8 W Cerritos Ave #54
Lenna,Paprocki,Feltz Printing Service,639 Main St,Anchorage
Donette,Foller,Printing Dimensions,34 Center St,Hamilton
Simona,Morasca,"Chapman, Ross E Esq",3 Mcauley Dr &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt; I am using the below code to keep the double quotes as its from the csv file.(few rows having double quotes and few dont) &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;val df_usdata    = spark.read.format("com.databricks.spark.csv")// 
.option("header","true")//
.option("quote","\"")// 
.load("file:///E://data//csvdata.csv")
df_usdata.show(false)     &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But it didn't preserve the double quotes inside the dataframe but it should be. &lt;/P&gt;
&lt;P&gt;The .option("quote","\"") is not working. Am using Spark 2.3.1 version. &lt;/P&gt;
&lt;P&gt; The output should be like below. &lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;+----------+---------+-------------------------+---------------------+
|first_name|last_name|company_name             |address              | 
+----------+---------+-------------------------+---------------------+ 
|James     |Butt     |"Benton, John B Jr"      |6649 N Blue Gum St   |
|Josephine |Darakjy  |"Chanay, Jeffrey A Esq"  |4 B Blue Ridge Blvd  |
|Art       |Venere   |"Chemel, James L Cpa"    |8 W Cerritos Ave #54 |
|Lenna     |Paprocki |Feltz Printing Service   |639 Main St          | 
|Donette   |Foller   |Printing Dimensions      |34 Center St         | 
|Simona    |Morasca  |"Chapman, Ross E Esq"    |3 Mcauley Dr         |
+----------+---------+-------------------------+---------------------+ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards, Dinesh Kumar&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 16:52:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27086#M18986</guid>
      <dc:creator>DineshKumar</dc:creator>
      <dc:date>2020-08-24T16:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27087#M18987</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;When I tried with &lt;PRE&gt;&lt;CODE&gt;.option("quote","")&lt;/CODE&gt;&lt;/PRE&gt; and .option("quote","\u0000") the company_name column values got splitted into next column like below.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;+----------+---------+-------------------------+---------------------+
|first_name|last_name|company_name             |address              |
+----------+---------+-------------------------+---------------------+
|James     |Butt     |"Benton                  | John B Jr"          |
|Josephine |Darakjy  |"Chanay                  | Jeffrey A Esq"      |
|Art       |Venere   |"Chemel                  | James L Cpa"        |
|Lenna     |Paprocki |Feltz Printing Service   |639 Main St          |
|Donette   |Foller   |Printing Dimensions      |34 Center St         |
|Simona    |Morasca  |"Chapman                 | Ross E Esq"         |
+----------+---------+-------------------------+---------------------+&lt;/CODE&gt;&lt;/PRE&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Aug 2020 16:02:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27087#M18987</guid>
      <dc:creator>DineshKumar</dc:creator>
      <dc:date>2020-08-25T16:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27088#M18988</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Try using both of these options :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;.option("quote", "\"") &lt;P&gt;&lt;/P&gt;.option("escape", "\"") 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Aug 2021 09:16:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27088#M18988</guid>
      <dc:creator>Forum_Admin</dc:creator>
      <dc:date>2021-08-06T09:16:48Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27089#M18989</link>
      <description>&lt;P&gt;Thanks, it resolves my issue with the csv generation&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 10:29:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27089#M18989</guid>
      <dc:creator>ManishRana</dc:creator>
      <dc:date>2022-01-21T10:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27090#M18990</link>
      <description>&lt;P&gt;Hai Currently,I am also facing same issue,please let me know how this issue resolved.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Munni&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 05:15:06 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/27090#M18990</guid>
      <dc:creator>Munni</dc:creator>
      <dc:date>2022-09-15T05:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Spark Read CSV doesn't preserve the double quotes while reading!</title>
      <link>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/39548#M27009</link>
      <description>&lt;P&gt;Hi Team,&lt;/P&gt;&lt;P&gt;I am also facing same issue and i have applied all the option mentioned from above posts:&lt;/P&gt;&lt;P&gt;I will just post my dataset here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LearningAj_0-1691694163947.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/3112i2F57241E235B334F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LearningAj_0-1691694163947.png" alt="LearningAj_0-1691694163947.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Attached is the my input data with 3 different column out of which&amp;nbsp;&lt;STRONG&gt;comment &lt;/STRONG&gt;column contains text value with double quotes and commas and to read this dataset i ave used all escape options but still &lt;STRONG&gt;comment&lt;/STRONG&gt;&amp;nbsp;column's data is moving to third column.&lt;/P&gt;&lt;P&gt;Below is the dataset from csv after performing read:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LearningAj_1-1691694446508.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/3113i8727291D74279865/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LearningAj_1-1691694446508.png" alt="LearningAj_1-1691694446508.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you please help on this issue ASAP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 19:08:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/spark-read-csv-doesn-t-preserve-the-double-quotes-while-reading/m-p/39548#M27009</guid>
      <dc:creator>LearningAj</dc:creator>
      <dc:date>2023-08-10T19:08:21Z</dc:date>
    </item>
  </channel>
</rss>

