Output Formats

We have seen how queries in RAW can read data from multiple input formats.

But RAW can also output data in multiple formats. That is, a RAW query can output data directly in a given format. That's because the output in RAW is a stream of data.

For this, however, we cannot use the Jupyter Magic, since that is configured to output data in a format specific for Python and Jupyter notebooks. If we use instead the Python CLI API (or the command-line tools), we can see this behaviour.

We start by initializing the RAW Python API:

Then let's do a query and ask for its output in the CSV format. For this we use the RAW Python API query_as method, which receives the query and the output format as arguments.

Let's now re-do the same query, requesting a JSON output.

This ability to generate output in multiple formats helps RAW integrate with external tools. The output format is always part of a query request: in the case of Jupyter notebooks, the user does not need to specify this since RAW's Jupyter client specifies it internally, requesting output in a format convenient for use in Jupyter.

Next: Querying Web Services