Skip to content

Commit

Permalink
Merge pull request #43 from gogovan/AN-5933
Browse files Browse the repository at this point in the history
An 5933
  • Loading branch information
ggx-jacechun authored Nov 6, 2023
2 parents 62caf78 + 209f3e9 commit 1877444
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions ggvlib/google/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import numpy as np



DEFAULT_SCOPES = [
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/drive.file",
Expand Down Expand Up @@ -68,18 +67,25 @@ def get_raw_responses_as_df(form_id: str) -> pd.DataFrame:
responses = get_raw_responses(form_id)
if "responses" in responses.keys():
for row in responses["responses"]:
# logger.info(row)
return_list = list()
return_list.append(row["responseId"])
return_list.append(row["createTime"])
return_list.append(row["lastSubmittedTime"])
return_list.append(row["answers"])
col_names = ["responseId", "createTime", "LastSubmittedTime", "answer"]
for val in row["answers"].values():
for answer in list(val.values())[1].values():
# for elem in list(val.values()):
# if type(elem) == dict and elem.get("answers"):
# for ans in elem.get("answers"):
# logger.info(ans)
# if "value" in list(ans[0].keys()):
# col_names.append(val["questionId"])
# return_list.append(ans[0]["value"])
for answer in list(val.values())[2].values():
if "value" in list(answer[0].keys()):
col_names.append(val["questionId"])
return_list.append(answer[0]["value"])

return_df = pd.concat([return_df, pd.DataFrame(return_list).T]).reset_index(
drop=True
)
Expand Down Expand Up @@ -160,4 +166,3 @@ def get_responses_as_df(form_id: str) -> pd.DataFrame:
name_dict[id] = name
return_df = response.rename(columns=name_dict)
return return_df

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "ggvlib"
version = "0.2.44"
version = "0.2.45"

description = ""
authors = ["Adam Hoffstein <[email protected]>","Jace Chun <[email protected]>"]
Expand Down

0 comments on commit 1877444

Please sign in to comment.