In: Computer Science
There is a lot of repeating data in the file example below in the form of key names being in each and every record. This is a tradeoff to allow each record to have a different mix of (or even entirely different) keys. CSV files generally have one record (the first one in the file) which is simply a record of each headers (or "key") for each column and every record has the same fields and keys.
My tsv2json utility has but one argument: tsv2json [-c | --compact]
This lets you use the CSV approach when you know every record contains the same fields.
What are the plusses and minuses of each approach? Also, what are your thoughts on redundancy and size, and processing-convenience in file formats?
File Example:
[ { "type": "act", "line_id": 1, "play_name": "Henry IV", "speech_number": "", "line_number": "", "speaker": "", "text_entry": "ACT I" }, … { "type": "line", "line_id": 111396, "play_name": "A Winters Tale", "speech_number": 38, "line_number": "", "speaker": "LEONTES", "text_entry": "Exeunt" } ]
JSON is ‘JavaScript Object Notation’. It is used as the syntax for storing and exchanging the data. It is a language-independent format. It is referred to as a lightweight data-interchange format. It is easy to understand. Its filename extension is .json
CSV is ‘Comma Separated Value’. It is a delimiting text that uses the comma to separate the file. In the CSV file, the tabular data has been saved as plain text data, separated by the comma. CSV formats are widely used to represent the sequence of records in which each record has an identical list of fields. Its filename extension is .csv and its internet media type is text/CSV.
Below mentioned are the Pros and Cons of each approach with processing convinience and file size aspects.
CSV characteristics:
Pros:-
Cons:-
JSON characteristics:
Pros:-
Cons:-
It has no error handling for JSON calls. If the dynamic script insertion works, you get called and will get the response perfectly. If not inserted, nothing happens. It just fails silently.
In short if we are considering the size aspects, CSV will be the firts choice, but performance and flexibility aspects will made you choose JSON format.