GitHub PullRequestReviewCommentEvent at 2014-10-09 23:43:43
Repository: synapsePythonClient
Actor: brucehoff
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/comments/18681797","id":18681797,"diff_hunk":"@@ -364,3 +502,137 @@ def next(self):\n             else:\n                 raise StopIteration()\n         return self.rowset['rows'][self.i]\n+\n+\n+class CsvFileTable(Table):\n+    \"\"\"\n+    An object to wrap a CSV file that may be stored into a Synapse table or\n+    returned as a result of a table query.\n+    \"\"\"\n+\n+    @classmethod\n+    def from_table_query(cls, synapse, query, quoteCharacter='\"', escapeCharacter=\"\\\\\", lineEnd=os.linesep, separator=\",\", header=True, includeRowIdAndRowVersion=True):\n+        \"\"\"\n+        Create a Table object wrapping a CSV file resulting from querying a Synapse table.\n+        Mostly for internal use.\n+        \"\"\"\n+\n+        download_from_table_result, file_info = synapse._queryTableCsv(\n+            query=query,\n+            quoteCharacter=quoteCharacter,\n+            escapeCharacter=escapeCharacter,\n+            lineEnd=os.linesep,\n+            separator=separator,\n+            header=header,\n+            includeRowIdAndRowVersion=includeRowIdAndRowVersion)\n+\n+        self = cls(\n+            filepath=file_info['path'],\n+            schema=download_from_table_result.get('tableId', None),\n+            updateEtag=download_from_table_result.get('etag', None),\n+            quoteCharacter=quoteCharacter,\n+            escapeCharacter=escapeCharacter,\n+            lineEnd=os.linesep,\n+            separator=separator,\n+            header=header,\n+            includeRowIdAndRowVersion=includeRowIdAndRowVersion)\n+\n+        self.setColumns(\n+            columns=list(synapse.getColumns(download_from_table_result['headers'])),\n+            headers= ['ROW_ID', 'ROW_VERSION'] + download_from_table_result['headers'] if includeRowIdAndRowVersion else download_from_table_result['headers'])\n+\n+        return self\n+\n+    def __init__(self, schema, filepath, updateEtag=None, quoteCharacter='\"', escapeCharacter=\"\\\\\", lineEnd=os.linesep, separator=\",\", header=True, linesToSkip=0, includeRowIdAndRowVersion=True, columns=None):\n+        self.filepath = filepath\n+        self.schema = schema\n+        self.updateEtag = updateEtag\n+        self.linesToSkip = linesToSkip\n+        self.includeRowIdAndRowVersion = includeRowIdAndRowVersion\n+\n+        ## CsvTableDescriptor fields\n+        self.quoteCharacter = quoteCharacter\n+        self.escapeCharacter = escapeCharacter\n+        self.lineEnd = lineEnd\n+        self.separator = separator\n+        self.header = header\n+\n+\n+    def _synapse_store(self, syn):\n+        if isinstance(self.schema, Schema) and self.schema.get('id', None) is None:\n+            ## store schema\n+            self.schema = syn.store(self.schema)\n+\n+        upload_to_table_result = syn._uploadCsv(\n+            self.filepath,\n+            self.schema,\n+            updateEtag=self.updateEtag,\n+            quoteCharacter=self.quoteCharacter,\n+            escapeCharacter=self.escapeCharacter,\n+            lineEnd=self.lineEnd,\n+            separator=self.separator,\n+            header=self.header,\n+            linesToSkip=self.linesToSkip)\n+\n+        self.updateEtag = upload_to_table_result['etag']\n+        return self\n+\n+    def asDataFrame(self):\n+        test_import_pandas()\n+        import pandas as pd\n+\n+        if self.includeRowIdAndRowVersion:\n+            df = pd.DataFrame.from_csv(self.filepath, header=0, sep=self.separator)\n+            ## combine row-ids (in index) and row-versions (in column 0) to\n+            ## make new row labels consisting of the row id and version\n+            ## separated by a dash.\n+            return pd.DataFrame(data=df.ix[:,1:], index=[\"%s-%s\"%(r,v) for r,v in zip(df.index,df.ix[:,0])])\n+        else:\n+            return pd.DataFrame.from_csv(self.filepath, header=0, sep=self.separator)\n+\n+    def asRowSet(self):\n+        return RowSet(headers=self.headers,\n+                      tableId=self.tableId,\n+                      etag=self.etag,\n+                      rows=[row for row in self])\n+\n+    def asInteger(self):\n+        raise NotImplementedError\n+\n+    def setColumns(self, columns, headers=None):\n+        \"\"\"\n+        Set the list of :py:class:`synapseclient.table.Column` objects that\n+        will be used to convert fields to the appropriate data types.\n+\n+        Columns are automatically set when querying.\n+        \"\"\"\n+        self.columns = columns\n+\n+        ## if we're given headers (a list of column ids) use those\n+        ## otherwise, we should be given a list of columns in the\n+        ## order they appear in the table\n+        if headers:\n+            self._headers = headers\n+        else:\n+            self._headers = [id_of(column) for column in columns]\n+\n+    def _synapse_delete(self, syn):\n+        \"\"\"\n+        Delete the rows that result from a table query.\n+        Example::\n+            syn.delete(syn.queryTable('select name from %s where no_good = true' % schema1.id))","path":"synapseclient/table.py","position":466,"original_position":466,"commit_id":"35a91fec305b9c549fc3b5ebf99ae6855047660e","original_commit_id":"35a91fec305b9c549fc3b5ebf99ae6855047660e","user":{"login":"brucehoff","id":1627352,"avatar_url":"https://avatars.githubusercontent.com/u/1627352?v=2","gravatar_id":"","url":"https://api.github.com/users/brucehoff","html_url":"https://github.com/brucehoff","followers_url":"https://api.github.com/users/brucehoff/followers","following_url":"https://api.github.com/users/brucehoff/following{/other_user}","gists_url":"https://api.github.com/users/brucehoff/gists{/gist_id}","starred_url":"https://api.github.com/users/brucehoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brucehoff/subscriptions","organizations_url":"https://api.github.com/users/brucehoff/orgs","repos_url":"https://api.github.com/users/brucehoff/repos","events_url":"https://api.github.com/users/brucehoff/events{/privacy}","received_events_url":"https://api.github.com/users/brucehoff/received_events","type":"User","site_admin":false},"body":"please use a distinct method name for deleting rows, e.g. syn.deleteRows().  Make it the same as the method name used in the R client.","created_at":"2014-10-09T23:43:43Z","updated_at":"2014-10-09T23:43:43Z","html_url":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171#discussion_r18681797","pull_request_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171","_links":{"self":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/comments/18681797"},"html":{"href":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171#discussion_r18681797"},"pull_request":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171"}}},"pull_request":{"url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171","id":22524523,"html_url":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171","diff_url":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171.diff","patch_url":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171.patch","issue_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/171","number":171,"state":"open","locked":false,"title":"Csv table queries","user":{"login":"cbare","id":170360,"avatar_url":"https://avatars.githubusercontent.com/u/170360?v=2","gravatar_id":"","url":"https://api.github.com/users/cbare","html_url":"https://github.com/cbare","followers_url":"https://api.github.com/users/cbare/followers","following_url":"https://api.github.com/users/cbare/following{/other_user}","gists_url":"https://api.github.com/users/cbare/gists{/gist_id}","starred_url":"https://api.github.com/users/cbare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbare/subscriptions","organizations_url":"https://api.github.com/users/cbare/orgs","repos_url":"https://api.github.com/users/cbare/repos","events_url":"https://api.github.com/users/cbare/events{/privacy}","received_events_url":"https://api.github.com/users/cbare/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-10-09T21:18:12Z","updated_at":"2014-10-09T23:43:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9975a1a59234f50808da2491598186d92774b757","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171/commits","review_comments_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171/comments","review_comment_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/171/comments","statuses_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/statuses/35a91fec305b9c549fc3b5ebf99ae6855047660e","head":{"label":"cbare:csv_table_queries","ref":"csv_table_queries","sha":"35a91fec305b9c549fc3b5ebf99ae6855047660e","user":{"login":"cbare","id":170360,"avatar_url":"https://avatars.githubusercontent.com/u/170360?v=2","gravatar_id":"","url":"https://api.github.com/users/cbare","html_url":"https://github.com/cbare","followers_url":"https://api.github.com/users/cbare/followers","following_url":"https://api.github.com/users/cbare/following{/other_user}","gists_url":"https://api.github.com/users/cbare/gists{/gist_id}","starred_url":"https://api.github.com/users/cbare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbare/subscriptions","organizations_url":"https://api.github.com/users/cbare/orgs","repos_url":"https://api.github.com/users/cbare/repos","events_url":"https://api.github.com/users/cbare/events{/privacy}","received_events_url":"https://api.github.com/users/cbare/received_events","type":"User","site_admin":false},"repo":{"id":5799950,"name":"synapsePythonClient","full_name":"cbare/synapsePythonClient","owner":{"login":"cbare","id":170360,"avatar_url":"https://avatars.githubusercontent.com/u/170360?v=2","gravatar_id":"","url":"https://api.github.com/users/cbare","html_url":"https://github.com/cbare","followers_url":"https://api.github.com/users/cbare/followers","following_url":"https://api.github.com/users/cbare/following{/other_user}","gists_url":"https://api.github.com/users/cbare/gists{/gist_id}","starred_url":"https://api.github.com/users/cbare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbare/subscriptions","organizations_url":"https://api.github.com/users/cbare/orgs","repos_url":"https://api.github.com/users/cbare/repos","events_url":"https://api.github.com/users/cbare/events{/privacy}","received_events_url":"https://api.github.com/users/cbare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cbare/synapsePythonClient","description":"Programmatic interface to Synapse services for Python. Please visit https://synapse.sagebase.org/ for more information.","fork":true,"url":"https://api.github.com/repos/cbare/synapsePythonClient","forks_url":"https://api.github.com/repos/cbare/synapsePythonClient/forks","keys_url":"https://api.github.com/repos/cbare/synapsePythonClient/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cbare/synapsePythonClient/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cbare/synapsePythonClient/teams","hooks_url":"https://api.github.com/repos/cbare/synapsePythonClient/hooks","issue_events_url":"https://api.github.com/repos/cbare/synapsePythonClient/issues/events{/number}","events_url":"https://api.github.com/repos/cbare/synapsePythonClient/events","assignees_url":"https://api.github.com/repos/cbare/synapsePythonClient/assignees{/user}","branches_url":"https://api.github.com/repos/cbare/synapsePythonClient/branches{/branch}","tags_url":"https://api.github.com/repos/cbare/synapsePythonClient/tags","blobs_url":"https://api.github.com/repos/cbare/synapsePythonClient/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cbare/synapsePythonClient/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cbare/synapsePythonClient/git/refs{/sha}","trees_url":"https://api.github.com/repos/cbare/synapsePythonClient/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cbare/synapsePythonClient/statuses/{sha}","languages_url":"https://api.github.com/repos/cbare/synapsePythonClient/languages","stargazers_url":"https://api.github.com/repos/cbare/synapsePythonClient/stargazers","contributors_url":"https://api.github.com/repos/cbare/synapsePythonClient/contributors","subscribers_url":"https://api.github.com/repos/cbare/synapsePythonClient/subscribers","subscription_url":"https://api.github.com/repos/cbare/synapsePythonClient/subscription","commits_url":"https://api.github.com/repos/cbare/synapsePythonClient/commits{/sha}","git_commits_url":"https://api.github.com/repos/cbare/synapsePythonClient/git/commits{/sha}","comments_url":"https://api.github.com/repos/cbare/synapsePythonClient/comments{/number}","issue_comment_url":"https://api.github.com/repos/cbare/synapsePythonClient/issues/comments/{number}","contents_url":"https://api.github.com/repos/cbare/synapsePythonClient/contents/{+path}","compare_url":"https://api.github.com/repos/cbare/synapsePythonClient/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cbare/synapsePythonClient/merges","archive_url":"https://api.github.com/repos/cbare/synapsePythonClient/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cbare/synapsePythonClient/downloads","issues_url":"https://api.github.com/repos/cbare/synapsePythonClient/issues{/number}","pulls_url":"https://api.github.com/repos/cbare/synapsePythonClient/pulls{/number}","milestones_url":"https://api.github.com/repos/cbare/synapsePythonClient/milestones{/number}","notifications_url":"https://api.github.com/repos/cbare/synapsePythonClient/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cbare/synapsePythonClient/labels{/name}","releases_url":"https://api.github.com/repos/cbare/synapsePythonClient/releases{/id}","created_at":"2012-09-13T19:43:45Z","updated_at":"2014-09-30T00:13:09Z","pushed_at":"2014-10-09T08:41:35Z","git_url":"git://github.com/cbare/synapsePythonClient.git","ssh_url":"git@github.com:cbare/synapsePythonClient.git","clone_url":"https://github.com/cbare/synapsePythonClient.git","svn_url":"https://github.com/cbare/synapsePythonClient","homepage":"","size":2794,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"Sage-Bionetworks:develop","ref":"develop","sha":"78fcd9fc9ac535c9b286b7dfe8b9ede6e8f0f17e","user":{"login":"Sage-Bionetworks","id":1250897,"avatar_url":"https://avatars.githubusercontent.com/u/1250897?v=2","gravatar_id":"","url":"https://api.github.com/users/Sage-Bionetworks","html_url":"https://github.com/Sage-Bionetworks","followers_url":"https://api.github.com/users/Sage-Bionetworks/followers","following_url":"https://api.github.com/users/Sage-Bionetworks/following{/other_user}","gists_url":"https://api.github.com/users/Sage-Bionetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/Sage-Bionetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sage-Bionetworks/subscriptions","organizations_url":"https://api.github.com/users/Sage-Bionetworks/orgs","repos_url":"https://api.github.com/users/Sage-Bionetworks/repos","events_url":"https://api.github.com/users/Sage-Bionetworks/events{/privacy}","received_events_url":"https://api.github.com/users/Sage-Bionetworks/received_events","type":"Organization","site_admin":false},"repo":{"id":5497036,"name":"synapsePythonClient","full_name":"Sage-Bionetworks/synapsePythonClient","owner":{"login":"Sage-Bionetworks","id":1250897,"avatar_url":"https://avatars.githubusercontent.com/u/1250897?v=2","gravatar_id":"","url":"https://api.github.com/users/Sage-Bionetworks","html_url":"https://github.com/Sage-Bionetworks","followers_url":"https://api.github.com/users/Sage-Bionetworks/followers","following_url":"https://api.github.com/users/Sage-Bionetworks/following{/other_user}","gists_url":"https://api.github.com/users/Sage-Bionetworks/gists{/gist_id}","starred_url":"https://api.github.com/users/Sage-Bionetworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sage-Bionetworks/subscriptions","organizations_url":"https://api.github.com/users/Sage-Bionetworks/orgs","repos_url":"https://api.github.com/users/Sage-Bionetworks/repos","events_url":"https://api.github.com/users/Sage-Bionetworks/events{/privacy}","received_events_url":"https://api.github.com/users/Sage-Bionetworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sage-Bionetworks/synapsePythonClient","description":"Programmatic interface to Synapse services for Python","fork":false,"url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient","forks_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/forks","keys_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/teams","hooks_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/hooks","issue_events_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/events{/number}","events_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/events","assignees_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/assignees{/user}","branches_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/branches{/branch}","tags_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/tags","blobs_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/statuses/{sha}","languages_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/languages","stargazers_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/stargazers","contributors_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/contributors","subscribers_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/subscribers","subscription_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/subscription","commits_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/comments/{number}","contents_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/contents/{+path}","compare_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/merges","archive_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/downloads","issues_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues{/number}","pulls_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls{/number}","milestones_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/milestones{/number}","notifications_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/labels{/name}","releases_url":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/releases{/id}","created_at":"2012-08-21T15:32:00Z","updated_at":"2014-09-02T08:17:17Z","pushed_at":"2014-10-03T18:55:49Z","git_url":"git://github.com/Sage-Bionetworks/synapsePythonClient.git","ssh_url":"git@github.com:Sage-Bionetworks/synapsePythonClient.git","clone_url":"https://github.com/Sage-Bionetworks/synapsePythonClient.git","svn_url":"https://github.com/Sage-Bionetworks/synapsePythonClient","homepage":"https://www.synapse.org","size":2908,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":4,"forks":14,"open_issues":4,"watchers":12,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171"},"html":{"href":"https://github.com/Sage-Bionetworks/synapsePythonClient/pull/171"},"issue":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/171"},"comments":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/issues/171/comments"},"review_comments":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171/comments"},"review_comment":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/pulls/171/commits"},"statuses":{"href":"https://api.github.com/repos/Sage-Bionetworks/synapsePythonClient/statuses/35a91fec305b9c549fc3b5ebf99ae6855047660e"}}}}