Database Reference
In-Depth Information
Another problem (which we will explore in the next section) is that CSV files are
not necessarily human readable; a file that describes a collection of numerical values
will be difficult to understand at a glance as it will appear to just be a mishmash of
numbers.
Choose CSV when your data is easily expressed in a flat row or if you want to
ensure compatibility with nearly everything. CSV format is easy to parse and load,
and it will always be easily supported by spreadsheets, databases, and all kinds of other
software applications due to its ubiquity. However, don't expect CSV to do anything
special; it's not a format that is going to go out of its way to help you. If your audience
is more likely to be less technical, CSV may be a good fit. If you expect your data to
be used by software developers, they may prefer structured data formats such as JSON
(see ahead).
XML: Data, Describe Thyself
If you've worked with data of any kind, you've certainly encountered the Extensible
Markup Language, or XML . Because of its widespread use and software support,
XML is another obvious contender for being the primary file format for sharing huge
numbers of files with your consumers.
XML is the way to go to store structured source files from which you can convert
to another format. For example, if you have a collection of structured documents that
may need to be transformed into a variety of other formats, XML is a great choice to
use as the “source of truth” file format.
JSON: The Programmer's Choice
XML is the best at what it was designed for—document interoperability—but it's not
always the best choice as a format for hosting a large collection of files. In some cases,
the overhead of XML's structure and mission does not match well with the object-
oriented focus of many programming languages.
JSON (which stands for JavaScript Object Notation) is a data interchange specifica-
tion that has gained much popularity with developers. As the name implies, a JSON
object is valid JavaScript, so it is obviously an easy data format to use for JavaScript
applications. However, JSON is not just for JavaScript, as parsers exist for many major
programming languages.
JSON syntax is very simple, and often models data much closer to the original state
than the corresponding XML representation. In other words, because XML is struc-
tured in a tree-like model, in some cases using it in an object-oriented programming
environment can be difficult. XML's model and extensibility features mean that it can
model any type of data, but there are cases in which the overhead of pulling out nodes
from an XML object is less convenient that simply referring to the data in object nota-
tion as with JSON. A file in JSON can potentially be faster to parse than a similar
document encoded in XML due to a lighter-weight syntax. Placing a collection of
newline-delimited JSON objects together in a file makes the format easy to parse pro-
grammatically, in the same way that CSV provides sequential access to data.
 
Search WWH ::




Custom Search