diff options
author | Jurriaan Pruis <email@jurriaanpruis.nl> | 2016-07-08 11:45:41 -0700 |
---|---|---|
committer | Reynold Xin <rxin@databricks.com> | 2016-07-08 11:45:41 -0700 |
commit | 38cf8f2a50068f80350740ac28e31c8accd20634 (patch) | |
tree | f86ea19bcb87b7b44ffdbf8092e1bd56e8bb5000 /python/pyspark | |
parent | 255d74fe4a0db2cc842177ec735bbde07c7c8732 (diff) | |
download | spark-38cf8f2a50068f80350740ac28e31c8accd20634.tar.gz spark-38cf8f2a50068f80350740ac28e31c8accd20634.tar.bz2 spark-38cf8f2a50068f80350740ac28e31c8accd20634.zip |
[SPARK-13638][SQL] Add quoteAll option to CSV DataFrameWriter
## What changes were proposed in this pull request?
Adds an quoteAll option for writing CSV which will quote all fields.
See https://issues.apache.org/jira/browse/SPARK-13638
## How was this patch tested?
Added a test to verify the output columns are quoted for all fields in the Dataframe
Author: Jurriaan Pruis <email@jurriaanpruis.nl>
Closes #13374 from jurriaan/csv-quote-all.
Diffstat (limited to 'python/pyspark')
-rw-r--r-- | python/pyspark/sql/readwriter.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/python/pyspark/sql/readwriter.py b/python/pyspark/sql/readwriter.py index 78d992e415..f7c354f513 100644 --- a/python/pyspark/sql/readwriter.py +++ b/python/pyspark/sql/readwriter.py @@ -633,7 +633,7 @@ class DataFrameWriter(OptionUtils): @since(2.0) def csv(self, path, mode=None, compression=None, sep=None, quote=None, escape=None, - header=None, nullValue=None, escapeQuotes=None): + header=None, nullValue=None, escapeQuotes=None, quoteAll=None): """Saves the content of the :class:`DataFrame` in CSV format at the specified path. :param path: the path in any Hadoop supported file system @@ -658,6 +658,9 @@ class DataFrameWriter(OptionUtils): :param escapeQuotes: A flag indicating whether values containing quotes should always be enclosed in quotes. If None is set, it uses the default value ``true``, escaping all values containing a quote character. + :param quoteAll: A flag indicating whether all values should always be enclosed in + quotes. If None is set, it uses the default value ``false``, + only escaping values containing a quote character. :param header: writes the names of columns as the first line. If None is set, it uses the default value, ``false``. :param nullValue: sets the string representation of a null value. If None is set, it uses @@ -667,7 +670,7 @@ class DataFrameWriter(OptionUtils): """ self.mode(mode) self._set_opts(compression=compression, sep=sep, quote=quote, escape=escape, header=header, - nullValue=nullValue, escapeQuotes=escapeQuotes) + nullValue=nullValue, escapeQuotes=escapeQuotes, quoteAll=quoteAll) self._jwrite.csv(path) @since(1.5) |