Skip to content

Empty files and header only #7

@FranklySpeaking23

Description

@FranklySpeaking23

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions