-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hello,
After reading the CSV specification on csv-spec.org, I have 2 questions:
-
What should happen when an empty file is converted from CSV to JSON? Should there be an error message telling the user that you cannot convert an empty file, should the program just create an empty list or does something else need to happen?
-
In clause 3 is stated:
There may be an OPTIONAL header line appearing as the first line of the file with the same format as normal records.
And in the example it gets convert in the following way:
CSV:
field_1,field_2,field_3¬ aaa,bbb,ccc¬ xxx,yyy,zzz¬JSON (using headers):
[ {"field_1": "aaa", "field_2": "bbb", "field_3": "ccc"}, {"field_1": "xxx", "field_2": "yyy", "field_3": "zzz"} ]But what if a CSV file only has one line, for example the
field_1,field_2,field_3line. Because the header is optional, there is no problem when the file is interpreted without a header, but if the user/program says that the file should have a header, than there are no values for those headers. In this example, there wouldn't be a valueaaaorxxxto give to the headerfield_1, making it so the header doesn't exist in the program and that there is no data loaded from the file. Should these headers than only be used when the program wants to add data to an existing header? Or should there be an error / something else?
I don't think these questions are answered in the specification, but my apologies if I looked over them.
Thank you.