1 |
On Mon, 12 Aug 2019 09:52:40 -0700 |
2 |
Alec Warner <antarus@g.o> wrote: |
3 |
|
4 |
> CSV, JSON and YAML are both popular machine-and-people readable |
5 |
> specifications with broad support. |
6 |
|
7 |
No, not CSV. There isn't really "a spec" for that. Even though there is |
8 |
a "proposed spec", "CSV editors" and things that emit CSV just make up |
9 |
their own rules. |
10 |
|
11 |
The more I know about CSV, the less I want anything to do with it. |
12 |
|
13 |
In essence, to make CSV viable (or any other delimiter-seperated format |
14 |
viable), you have to locally redefine what that means to a limited |
15 |
subset of the spec. |
16 |
|
17 |
For instance, forbid the feature where the first line is the string |
18 |
"Sep=,"[1], which tools like Excel (may) generate, but aren't spec |
19 |
compliant, and leads to ... interesting things. |
20 |
|
21 |
But pretty much you can take it for granted that a '.csv' extension |
22 |
will make *somebody* make assumptions about the format that aren't true. |
23 |
|
24 |
Like for instance, is leading/trailing whitespace around delimiters |
25 |
significant? Spec says yes[2], but implementations may desire it to be |
26 |
no ( And gentoo probably prefers them not to be significant for |
27 |
alignment reasons ) |
28 |
|
29 |
As for JSON/YAML, ... eh... that may be the case for like, 4 line files. |
30 |
|
31 |
But once you have hundreds of entries, that becomes less true. |
32 |
|
33 |
And both of those can have "Fun" merge conflict issues due to the |
34 |
requirements around record delimiters and syntax, |
35 |
|
36 |
eg: You're using JSON, does your JSON formatter emit every record on |
37 |
its own line? No? That's going to create annoying merge conflicts. |
38 |
|
39 |
Does your formatter/decoder support trailing "," ? |
40 |
No? That's going to introduce problems. |
41 |
|
42 |
That's why I'd rather a more narrow, less general, domain specific |
43 |
format, instead of throwing these general tools at the problem. |
44 |
|
45 |
1: https://en.wikipedia.org/wiki/Comma-separated_values#General_functionality |
46 |
2: https://en.wikipedia.org/wiki/Comma-separated_values#Basic_rules |