Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty files and header only #7

Open
FranklySpeaking23 opened this issue Aug 2, 2024 · 0 comments
Open

Empty files and header only #7

FranklySpeaking23 opened this issue Aug 2, 2024 · 0 comments

Comments

@FranklySpeaking23
Copy link

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_3 line. 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 value aaa or xxx to give to the header field_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant