{"action":"created","comment":{"url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/comments/92060808","pull_request_review_id":12569675,"id":92060808,"diff_hunk":"@@ -0,0 +1,80 @@\n+import requests\n+import serenytics\n+import pandas as pd\n+import io\n+import logging\n+\n+SERENYTICS_NAME = 'Load a file source into a Serenytics storage'\n+SERENYTICS_UUID = '989a8c60-f11f-4098-b27a-da4df34e592c'\n+SERENYTICS_VERSION = '{{SERENYTICS_VERSION}}'\n+\n+SERENYTICS_PARAMS = [\n+    {\n+        'name': 'input_source',\n+        'desc': 'Input Source (CSV or XLS file)',\n+        'type': 'SOURCE_UUID'\n+    },\n+    {\n+        'name': 'output_source',\n+        'desc': 'Output Storage',\n+        'type': 'SOURCE_UUID'\n+    }\n+]\n+\n+\n+INPUT_UUID = serenytics.script_params.get('input_source')\n+OUTPUT_UUID = serenytics.script_params.get('output_source')\n+\n+client = serenytics.Client()\n+params = client.script_args\n+api_key = params.get('SERENYTICS_API_KEY')\n+\n+source = client.get_data_source_by_uuid(uuid=INPUT_UUID)\n+\n+headers = {\n+    'X-Api-Key': api_key,\n+    'Content-type': 'application/json'\n+}\n+\n+url = 'https://api.serenytics.com/api/data_source/' + INPUT_UUID + '/file'\n+\n+if source.type == \"CSVFile\":\n+    logging.info('--- Get data from source')\n+    headers['mimetype'] = 'text/csv'\n+\n+    if 'separator' in source._config['jsonContent']:\n+        separator = source._config['jsonContent']['separator']\n+    else:\n+        separator = ';'\n+\n+    r = requests.get(url, headers=headers)\n+\n+    fo = open(\"tmp.csv\", \"w\")\n+    fo.write(r.content)\n+    fo.close()\n+elif source.type == \"XLSFile\":\n+    logging.info('--- Get data from source')\n+    headers['mimetype'] = 'text/xlsx'\n+    r = requests.get(url, headers=headers)\n+\n+    # get sheetname provided\n+    if 'worksheet' in source._config['jsonContent']:\n+        worksheet = source._config['jsonContent']['worksheet']\n+        df = pd.read_excel(io.BytesIO(r.content), sheetname=worksheet)\n+    else:\n+        df = pd.read_excel(io.BytesIO(r.content))\n+\n+    separator = ';'","path":"templates/file_to_storage.py","position":67,"original_position":67,"commit_id":"083c1a139043158308c471b2226df0e6a81086c3","original_commit_id":"083c1a139043158308c471b2226df0e6a81086c3","user":{"login":"achauve","id":296285,"avatar_url":"https://avatars.githubusercontent.com/u/296285?v=3","gravatar_id":"","url":"https://api.github.com/users/achauve","html_url":"https://github.com/achauve","followers_url":"https://api.github.com/users/achauve/followers","following_url":"https://api.github.com/users/achauve/following{/other_user}","gists_url":"https://api.github.com/users/achauve/gists{/gist_id}","starred_url":"https://api.github.com/users/achauve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/achauve/subscriptions","organizations_url":"https://api.github.com/users/achauve/orgs","repos_url":"https://api.github.com/users/achauve/repos","events_url":"https://api.github.com/users/achauve/events{/privacy}","received_events_url":"https://api.github.com/users/achauve/received_events","type":"User","site_admin":false},"body":"inline in following line?","created_at":"2016-12-12T22:58:06Z","updated_at":"2016-12-12T22:59:37Z","html_url":"https://github.com/Serenytics/serenytics-template-scripts/pull/4#discussion_r92060808","pull_request_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/comments/92060808"},"html":{"href":"https://github.com/Serenytics/serenytics-template-scripts/pull/4#discussion_r92060808"},"pull_request":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4","id":97639257,"html_url":"https://github.com/Serenytics/serenytics-template-scripts/pull/4","diff_url":"https://github.com/Serenytics/serenytics-template-scripts/pull/4.diff","patch_url":"https://github.com/Serenytics/serenytics-template-scripts/pull/4.patch","issue_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/4","number":4,"state":"open","locked":false,"title":"add a script to load a file source into a storage","user":{"login":"Adrien-Auclair","id":7556999,"avatar_url":"https://avatars.githubusercontent.com/u/7556999?v=3","gravatar_id":"","url":"https://api.github.com/users/Adrien-Auclair","html_url":"https://github.com/Adrien-Auclair","followers_url":"https://api.github.com/users/Adrien-Auclair/followers","following_url":"https://api.github.com/users/Adrien-Auclair/following{/other_user}","gists_url":"https://api.github.com/users/Adrien-Auclair/gists{/gist_id}","starred_url":"https://api.github.com/users/Adrien-Auclair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Adrien-Auclair/subscriptions","organizations_url":"https://api.github.com/users/Adrien-Auclair/orgs","repos_url":"https://api.github.com/users/Adrien-Auclair/repos","events_url":"https://api.github.com/users/Adrien-Auclair/events{/privacy}","received_events_url":"https://api.github.com/users/Adrien-Auclair/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-12T21:41:15Z","updated_at":"2016-12-12T22:59:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cfb4e2f2b0b7d0201eeee4640f4c8b727fdf8f5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4/commits","review_comments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4/comments","review_comment_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/4/comments","statuses_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/statuses/083c1a139043158308c471b2226df0e6a81086c3","head":{"label":"Serenytics:add-file-to-storage-script","ref":"add-file-to-storage-script","sha":"083c1a139043158308c471b2226df0e6a81086c3","user":{"login":"Serenytics","id":10116556,"avatar_url":"https://avatars.githubusercontent.com/u/10116556?v=3","gravatar_id":"","url":"https://api.github.com/users/Serenytics","html_url":"https://github.com/Serenytics","followers_url":"https://api.github.com/users/Serenytics/followers","following_url":"https://api.github.com/users/Serenytics/following{/other_user}","gists_url":"https://api.github.com/users/Serenytics/gists{/gist_id}","starred_url":"https://api.github.com/users/Serenytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Serenytics/subscriptions","organizations_url":"https://api.github.com/users/Serenytics/orgs","repos_url":"https://api.github.com/users/Serenytics/repos","events_url":"https://api.github.com/users/Serenytics/events{/privacy}","received_events_url":"https://api.github.com/users/Serenytics/received_events","type":"Organization","site_admin":false},"repo":{"id":46806273,"name":"serenytics-template-scripts","full_name":"Serenytics/serenytics-template-scripts","owner":{"login":"Serenytics","id":10116556,"avatar_url":"https://avatars.githubusercontent.com/u/10116556?v=3","gravatar_id":"","url":"https://api.github.com/users/Serenytics","html_url":"https://github.com/Serenytics","followers_url":"https://api.github.com/users/Serenytics/followers","following_url":"https://api.github.com/users/Serenytics/following{/other_user}","gists_url":"https://api.github.com/users/Serenytics/gists{/gist_id}","starred_url":"https://api.github.com/users/Serenytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Serenytics/subscriptions","organizations_url":"https://api.github.com/users/Serenytics/orgs","repos_url":"https://api.github.com/users/Serenytics/repos","events_url":"https://api.github.com/users/Serenytics/events{/privacy}","received_events_url":"https://api.github.com/users/Serenytics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Serenytics/serenytics-template-scripts","description":"Contains template scripts to use in Serenytics cloud analytics platform","fork":false,"url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts","forks_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/forks","keys_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/teams","hooks_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/hooks","issue_events_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/events","assignees_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/tags","blobs_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/languages","stargazers_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/stargazers","contributors_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/contributors","subscribers_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/subscribers","subscription_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/subscription","commits_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/merges","archive_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/downloads","issues_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/labels{/name}","releases_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/deployments","created_at":"2015-11-24T17:07:03Z","updated_at":"2016-11-15T16:59:26Z","pushed_at":"2016-12-12T21:41:16Z","git_url":"git://github.com/Serenytics/serenytics-template-scripts.git","ssh_url":"git@github.com:Serenytics/serenytics-template-scripts.git","clone_url":"https://github.com/Serenytics/serenytics-template-scripts.git","svn_url":"https://github.com/Serenytics/serenytics-template-scripts","homepage":"https://www.serenytics.com","size":9,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"Serenytics:master","ref":"master","sha":"ab29c515f1096674607ef4ebdfa4244ae3e13888","user":{"login":"Serenytics","id":10116556,"avatar_url":"https://avatars.githubusercontent.com/u/10116556?v=3","gravatar_id":"","url":"https://api.github.com/users/Serenytics","html_url":"https://github.com/Serenytics","followers_url":"https://api.github.com/users/Serenytics/followers","following_url":"https://api.github.com/users/Serenytics/following{/other_user}","gists_url":"https://api.github.com/users/Serenytics/gists{/gist_id}","starred_url":"https://api.github.com/users/Serenytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Serenytics/subscriptions","organizations_url":"https://api.github.com/users/Serenytics/orgs","repos_url":"https://api.github.com/users/Serenytics/repos","events_url":"https://api.github.com/users/Serenytics/events{/privacy}","received_events_url":"https://api.github.com/users/Serenytics/received_events","type":"Organization","site_admin":false},"repo":{"id":46806273,"name":"serenytics-template-scripts","full_name":"Serenytics/serenytics-template-scripts","owner":{"login":"Serenytics","id":10116556,"avatar_url":"https://avatars.githubusercontent.com/u/10116556?v=3","gravatar_id":"","url":"https://api.github.com/users/Serenytics","html_url":"https://github.com/Serenytics","followers_url":"https://api.github.com/users/Serenytics/followers","following_url":"https://api.github.com/users/Serenytics/following{/other_user}","gists_url":"https://api.github.com/users/Serenytics/gists{/gist_id}","starred_url":"https://api.github.com/users/Serenytics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Serenytics/subscriptions","organizations_url":"https://api.github.com/users/Serenytics/orgs","repos_url":"https://api.github.com/users/Serenytics/repos","events_url":"https://api.github.com/users/Serenytics/events{/privacy}","received_events_url":"https://api.github.com/users/Serenytics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Serenytics/serenytics-template-scripts","description":"Contains template scripts to use in Serenytics cloud analytics platform","fork":false,"url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts","forks_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/forks","keys_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/teams","hooks_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/hooks","issue_events_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/events{/number}","events_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/events","assignees_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/assignees{/user}","branches_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/branches{/branch}","tags_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/tags","blobs_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/refs{/sha}","trees_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/statuses/{sha}","languages_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/languages","stargazers_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/stargazers","contributors_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/contributors","subscribers_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/subscribers","subscription_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/subscription","commits_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/commits{/sha}","git_commits_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/git/commits{/sha}","comments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/comments{/number}","issue_comment_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/comments{/number}","contents_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/contents/{+path}","compare_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/merges","archive_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/downloads","issues_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues{/number}","pulls_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls{/number}","milestones_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/milestones{/number}","notifications_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/labels{/name}","releases_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/releases{/id}","deployments_url":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/deployments","created_at":"2015-11-24T17:07:03Z","updated_at":"2016-11-15T16:59:26Z","pushed_at":"2016-12-12T21:41:16Z","git_url":"git://github.com/Serenytics/serenytics-template-scripts.git","ssh_url":"git@github.com:Serenytics/serenytics-template-scripts.git","clone_url":"https://github.com/Serenytics/serenytics-template-scripts.git","svn_url":"https://github.com/Serenytics/serenytics-template-scripts","homepage":"https://www.serenytics.com","size":9,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4"},"html":{"href":"https://github.com/Serenytics/serenytics-template-scripts/pull/4"},"issue":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/4"},"comments":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/Serenytics/serenytics-template-scripts/statuses/083c1a139043158308c471b2226df0e6a81086c3"}}}}
{"actor":{"display_login":"achauve"}}