{"action":"opened","issue":{"url":"https://api.github.com/repos/Crunch-io/scrunch/issues/51","repository_url":"https://api.github.com/repos/Crunch-io/scrunch","labels_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/51/comments","events_url":"https://api.github.com/repos/Crunch-io/scrunch/issues/51/events","html_url":"https://github.com/Crunch-io/scrunch/issues/51","id":205278600,"number":51,"title":"Add metadata to scrunch's ds.download()","user":{"login":"xbito","id":205580,"avatar_url":"https://avatars.githubusercontent.com/u/205580?v=3","gravatar_id":"","url":"https://api.github.com/users/xbito","html_url":"https://github.com/xbito","followers_url":"https://api.github.com/users/xbito/followers","following_url":"https://api.github.com/users/xbito/following{/other_user}","gists_url":"https://api.github.com/users/xbito/gists{/gist_id}","starred_url":"https://api.github.com/users/xbito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xbito/subscriptions","organizations_url":"https://api.github.com/users/xbito/orgs","repos_url":"https://api.github.com/users/xbito/repos","events_url":"https://api.github.com/users/xbito/events{/privacy}","received_events_url":"https://api.github.com/users/xbito/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-02-03T21:50:13Z","updated_at":"2017-02-03T21:50:13Z","closed_at":null,"body":"Please add support to save the dataset metadata when using ds.download().\r\n\r\nFor example I changed the signature and added the following to the top of download method:\r\n\r\n    def download(self, path, path_metadata=None, filter=None, variables=None, hidden=True):\r\n        \"\"\"\r\n        Downloads a dataset as CSV to the given path.\r\n        this includes hidden variables and categories\r\n        as id's.\r\n        \"\"\"\r\n        if not path_metadata is None:\r\n            metadata = self.resource.table['metadata']\r\n            if not variables is None:\r\n                metadata = {\r\n                    key: value\r\n                    for key, value in metadata.iteritems()\r\n                    if value['alias'] in variables\r\n                }\r\n            with open(path_metadata, 'w+') as f:\r\n                json.dump(metadata, f, sort_keys=True)\r\n \r\nImportantly the metadata should be filtered to retain only those variables specified by the variables parameter (if any)."}}
{"actor":{"display_login":"xbito"}}