Why does Export-CSV put quotes around everything?
Sure, this is a valid CSV, technically, but it feels like a clunky
implmentation. Only values with delimiters within them should have to
be quoted.
Is there a way to turn this off and make it more RFC4180 compliant?
Thanks.
--
Kevin Buchan
kevin.buchan@troutman[nospam]sanders.com
|
|
0
|
|
|
|
Reply
|
Kevin
|
5/31/2010 7:42:27 PM |
|
Because its easier to quote everything rather than not. You can have
whitespace, embedded quotes, etc. C/C++ has taken this same approach when it
comes to several concepts one would be enums and the trailing ',' which is
ignored because many people would build these at compile time.
CVF files are not for human consumption; these are to be fed to applications.
Please point to the part that states adding non-essential quotes breaks
compatibility with this RFC. I'm not seeing it based on the section 2)
"Definition of the CSV format"
http://tools.ietf.org/html/rfc4180
5. Each field may or may not be enclosed in double quotes (however
some programs, such as Microsoft Excel, do not use double quotes
at all). If fields are not enclosed with double quotes, then
double quotes may not appear inside the fields. For example:
"aaa","bbb","ccc" CRLF
zzz,yyy,xxx
6. Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes. For example:
"aaa","b CRLF
bb","ccc" CRLF
zzz,yyy,xxx
7. If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote. For example:
"aaa","b""bb","ccc"
"Kevin Buchan" wrote:
> Why does Export-CSV put quotes around everything?
>
> Sure, this is a valid CSV, technically, but it feels like a clunky
> implmentation. Only values with delimiters within them should have to
> be quoted.
>
> Is there a way to turn this off and make it more RFC4180 compliant?
>
> Thanks.
>
> --
> Kevin Buchan
> kevin.buchan@troutman[nospam]sanders.com
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
6/1/2010 12:38:01 PM
|
|
"Please point to the part that states adding non-essential quotes
breaks compatibility with this RFC."
Of course, it does not have such a section. As I pointed out,
export-csv does, in fact, produce valid CSV.
My point was: Sure, it's valid, but I require more from the
developers on my Team than meeting "minimum expectations". I had my
most junior develper write a PoSh 2 function to accomplish the same
thing and his results in a (slightly) smaller file and executes in
less than 1/2 the time as export-csv. Sure, he spent way too much
time optimizing it for speed (we'll never get that day back) but it
was a good learning exercise for him.
For "middle of the night" operations that just transfer CSV data from
one system to another, we use the built in export-csv so that we have
no external dependencies but for time sensitive operations or when I
am producing a CSV file to be sent to an external partner, we use our
improved, home-grown version.
Perhaps I raised your ire by saying "make it more RFC4180 compliant"
because clealy it is fully compliant. I'm not sure why you seemed to
react emotionally to what was simply a request to the community.
-KB
On Tue, 1 Jun 2010 05:38:01 -0700, Bob Landau
<BobLandau@discussions.microsoft.com> wrote:
>
>Because its easier to quote everything rather than not. You can have
>whitespace, embedded quotes, etc. C/C++ has taken this same approach when it
>comes to several concepts one would be enums and the trailing ',' which is
>ignored because many people would build these at compile time.
>
>CVF files are not for human consumption; these are to be fed to applications.
>
>Please point to the part that states adding non-essential quotes breaks
>compatibility with this RFC. I'm not seeing it based on the section 2)
>"Definition of the CSV format"
>
>http://tools.ietf.org/html/rfc4180
>
> 5. Each field may or may not be enclosed in double quotes (however
> some programs, such as Microsoft Excel, do not use double quotes
> at all). If fields are not enclosed with double quotes, then
> double quotes may not appear inside the fields. For example:
>
> "aaa","bbb","ccc" CRLF
> zzz,yyy,xxx
>
> 6. Fields containing line breaks (CRLF), double quotes, and commas
> should be enclosed in double-quotes. For example:
>
> "aaa","b CRLF
> bb","ccc" CRLF
> zzz,yyy,xxx
>
> 7. If double-quotes are used to enclose fields, then a double-quote
> appearing inside a field must be escaped by preceding it with
> another double quote. For example:
>
> "aaa","b""bb","ccc"
>
>
>
>
>
>"Kevin Buchan" wrote:
>
>> Why does Export-CSV put quotes around everything?
>>
>> Sure, this is a valid CSV, technically, but it feels like a clunky
>> implmentation. Only values with delimiters within them should have to
>> be quoted.
>>
>> Is there a way to turn this off and make it more RFC4180 compliant?
>>
>> Thanks.
>>
>> --
>> Kevin Buchan
>> kevin.buchan@troutman[nospam]sanders.com
>> .
>>
|
|
0
|
|
|
|
Reply
|
Kevin
|
6/5/2010 4:18:29 PM
|
|
|
2 Replies
890 Views
(page loaded in 0.053 seconds)
|