P
P
PILITYXXX1232020-08-13 22:26:46
Python
PILITYXXX123, 2020-08-13 22:26:46

How to get a list of orders for a specific period in a google spreadsheet using python?

That's the point, there is a table - 5f3591e6910c3580012816.png

And there are 2 variables -

data = 2020-06-11 17:40:00
data1 = 2020-06-12 11:45:00

I need the result to be - 5f35931712afa486983865.png

That is, it is necessary to display those values ​​that are between data and data1

Well, my code is -

from pprint import pprint
import gspread
import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials
from collections import Counter

import collections


# Файл, полученный в Google Developer Console
CREDENTIALS_FILE = 'Bo-bed3d11d7dea.json'
# ID Google Sheets документа (можно взять из его URL)
spreadsheet_id = '1lCRA7Ui-QOH7Aipfbgsu4IA6eU5ZeXaCLgsdPoJKVVfI'

# Авторизуемся и получаем service — экземпляр доступа к API
credentials = ServiceAccountCredentials.from_json_keyfile_name(
    CREDENTIALS_FILE,
    ['https://www.googleapis.com/auth/spreadsheets',
     'https://www.googleapis.com/auth/drive'])
httpAuth = credentials.authorize(httplib2.Http())
service = apiclient.discovery.build('sheets', 'v4', http = httpAuth)

client = gspread.authorize(credentials)
sheet = client.open("Bo: вебин").sheet1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2020-08-14
@PILITYXXX123

1) Get values ​​from the desired range
2) Go through all the rows for , check for the condition
data>=row[data_col] and data1<row[data_col]
, where data_col is a column with dates in the source data
2*) As an option - use array filtering
3) Use the resulting array further
In the table itself, this can be done like this:
=filter(A:A;B:B>=data;B:B<data1)
where data , data1 are named ranges or cell references with your filter borders

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question