| Name | Description |
|--------------------------|---------------------------------------------------------------------------------------|
| Google.CreateSpreadsheet | Create a new spreadsheet with the provided
title and data in its first sheet |
| Google.GetSpreadsheet | Get the user entered and formatted data for
all sheets in the spreadsheet |
| Google.WriteToCell | Write a value to a single cell in a spreadsheet.
|
## Google.CreateSpreadsheet
This tool can create a new spreadsheet with data in its first sheet
This tool takes in the data as a JSON string. Here's an example input:
```
// Good at large payloads, sparse payloads, and contiguous data payloads.
// For example data[1]["D"] represents the value of the cell in the first row in the D column
{
// All data in row 1
1: {
"A": 42,
"B": 2,
"D":"=A1+B1"
},
// All data in row 54
54: {
"A": "my string",
"QQ": "my far away string"
}
}
```
The above data format performed better on evals than the other two that
I tested:
```
// Performed poorly at sparse data and also at larger amounts of data
[
[42, 2, "", "=A1+B1"],
[],
[],
...,
["A": "my string", "", "", ..., "my far away string"]
]
```
```
// Good at small payloads and sparse payloads, but very bad at payloads with contiguous data
{
"A1": 42", "B1": 2, "D1": "=A1+B1", "A54": "my string", "QQ": "my far away string"
}
```
## Google.GetSpreadsheet
Gets the formatted values for all non empty cells in all sheets of the
spreadsheet. The data returned is in a similar format as the
`Google.CreateSpreadsheet` tool's `data` input parameter. The difference
is that `get_spreadsheet` will return the user entered value (=A1+B1)
and also the formatted value (23.4) for each cell.
## Google.WriteToCell
Writes to a single cell. At this point in time we do not support batch
updating a sheet.
84 lines
2.6 KiB
Python
84 lines
2.6 KiB
Python
from arcade_google.models import SheetDataInput
|
|
|
|
|
|
def test_sheet_input_data_init():
|
|
data = '{"1":{"A":"name","B":"age","C":"email","D":"score","E":"gender","F":"city","G":"country","H":"registration_date"},"34":{"A":"Isla Green","B":24,"C":"islag@example.com","D":79,"E":"Female","F":"Chicago","G":"USA","H":"2024-01-10"},"38":{"A":"Mia Black","B":27,"C":"miab@example.com","D":80,"E":"Female","F":"Denver","G":"USA","H":"2024-01-30"},"39":{"A":"Nate Green","B":30,"C":"nateg@example.com","D":88,"E":"Male","F":"Orlando","G":"USA","H":"2024-02-01"},"43":{"A":100,"B":300,"C":234,"D":399,"E":5039,"F":2345,"G":23526,"H":123,"I":54,"J":234,"K":54,"L":23,"M":12,"N":57,"O":1324},"47":{"A":456,"B":234,"C":234,"D":399,"E":234,"F":1234,"G":23526,"H":123,"I":54,"J":234,"K":4567,"L":23,"M":12,"N":234,"O":1324}}'
|
|
expected_data = {
|
|
1: {
|
|
"A": "name",
|
|
"B": "age",
|
|
"C": "email",
|
|
"D": "score",
|
|
"E": "gender",
|
|
"F": "city",
|
|
"G": "country",
|
|
"H": "registration_date",
|
|
},
|
|
34: {
|
|
"A": "Isla Green",
|
|
"B": 24,
|
|
"C": "islag@example.com",
|
|
"D": 79,
|
|
"E": "Female",
|
|
"F": "Chicago",
|
|
"G": "USA",
|
|
"H": "2024-01-10",
|
|
},
|
|
38: {
|
|
"A": "Mia Black",
|
|
"B": 27,
|
|
"C": "miab@example.com",
|
|
"D": 80,
|
|
"E": "Female",
|
|
"F": "Denver",
|
|
"G": "USA",
|
|
"H": "2024-01-30",
|
|
},
|
|
39: {
|
|
"A": "Nate Green",
|
|
"B": 30,
|
|
"C": "nateg@example.com",
|
|
"D": 88,
|
|
"E": "Male",
|
|
"F": "Orlando",
|
|
"G": "USA",
|
|
"H": "2024-02-01",
|
|
},
|
|
43: {
|
|
"A": 100,
|
|
"B": 300,
|
|
"C": 234,
|
|
"D": 399,
|
|
"E": 5039,
|
|
"F": 2345,
|
|
"G": 23526,
|
|
"H": 123,
|
|
"I": 54,
|
|
"J": 234,
|
|
"K": 54,
|
|
"L": 23,
|
|
"M": 12,
|
|
"N": 57,
|
|
"O": 1324,
|
|
},
|
|
47: {
|
|
"A": 456,
|
|
"B": 234,
|
|
"C": 234,
|
|
"D": 399,
|
|
"E": 234,
|
|
"F": 1234,
|
|
"G": 23526,
|
|
"H": 123,
|
|
"I": 54,
|
|
"J": 234,
|
|
"K": 4567,
|
|
"L": 23,
|
|
"M": 12,
|
|
"N": 234,
|
|
"O": 1324,
|
|
},
|
|
}
|
|
|
|
sheet_input_data = SheetDataInput(data=data)
|
|
assert sheet_input_data.data == expected_data
|