openspending / babbage

A light-weight, OLAP-style analytical engine for Postgres (focused on OpenSpending)
MIT License
37 stars 16 forks source link

CSV return format #5

Open pudo opened 8 years ago

pudo commented 8 years ago

All HTTP API queries should be able to return a simple CSV response. In a fancy scenario, this would allow switching between naming the columns according to logical model fields and the original column names which are mentioned in the model.

This should use streaming responses, rather than pre-generating the full response.

pwalsh commented 8 years ago

Yes! This means Babbage itself can return a stream to write directly to a file server for static aggregation.

pwalsh commented 8 years ago

@akariv we'd certainly want to be able to write aggregate endpoints for a single package as CSV.

pwalsh commented 8 years ago

We are definitely doing this, but it might be in the next sprint so I'm putting on backlog for now.

jbothma commented 6 years ago

This seems to be implemented but generates invalid CSV when the values contain commas because it's just joining values with , https://github.com/openspending/babbage/blob/master/babbage/api.py#L75

It should probably use https://docs.python.org/2/library/csv.html#csv.DictWriter