From 4c1aea3a608d921d022635fca3043912d237226d Mon Sep 17 00:00:00 2001 From: Alexandre Lavigne Date: Mon, 15 Jan 2024 23:38:31 +0100 Subject: [PATCH] Add util function `to_record` to build records Add a new util function that helps building record values. Records are list of dictionaries, each dictionary has the same set of keys, they are set from the given list of headers. Each key is associated to a value from the given matrix of values. They are as many dictionaries as they are lines in the matrix. Each line in the matrix will be associated to a dictionary, each key is associated to a value from that line in the given order. Example: Headers: A B C Values: 1 2 3 7 8 9 Result: [ { A: 1, B: 2, C: 3}, {A: 7, B: 8, C: 9}] closes #1367 Signed-off-by: Alexandre Lavigne --- dev.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 dev.py diff --git a/dev.py b/dev.py new file mode 100644 index 000000000..91baf21b8 --- /dev/null +++ b/dev.py @@ -0,0 +1,12 @@ +from pprint import pp + +import gspread + +client = gspread.service_account() +file = client.open("TestGspread") +sh = file.sheet1 +range = "b16:d18" +values = sh.get_values(range) +pp(values) +values = sh.get(range, pad_values=True) +pp(values)