Conversation
There was a problem hiding this comment.
Might be easiest to just consume the CSV output by csv_observation_request. If you read the response into a StringIO buffer you could pass it to pandas using read_csv and you'd have the data as a DataFrame without having to manipulate the observations directly. There'd be no network bottleneck because there'd be no HTTP communication - we'd just use the responses.
The content would be accessible like this:
csv = csv_observation_request(request, station, start, end).content
# Continue processing|
Before the merge we need to add the following packages to
|
There was a problem hiding this comment.
It would be nice to build this so that png and csv are at the beginning, not at the end. Not sure how to best implement that - off the top of my head I'm thinking something like putting those up front and then passing them to a date_parser or something, somehow passing it the harvested request type so that it knows what function to call. I prefer that because that would be more consistent with line 31, where the pattern begins with the request type. Before the merge we'll need to find a DRY way of expressing that, or modify the API for requestion a station list.
I'm thinking something like this:
data_patterns = [
url(r'^(?P<content_type>[a-z]+)/' # Content type
r'^(?P<station>[0-9]+)/' # Station ID
r'(?P<start>[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2})' # Start date
r' - '
r'(?P<end>[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2})/', data_request),
url(r'csv$', csv_observation_request)And then in views.py something like:
DATA_TYPES_MAP = {"csv": csv_observation_request,
"png": png_observation_request}
def data_request(request, content_type, station, start, end):
"""Route a data request."""
return DATA_TYPES_MAP[content_type](request, station, start, end)Just a very rough prototype.
No description provided.