Skip to content

Commit

Permalink
Add util function to_record to build records
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
lavigne958 committed Jan 19, 2024
1 parent 7ddfd50 commit 4c1aea3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dev.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 4c1aea3

Please sign in to comment.