Answer the question
In order to leave comments, you need to log in
Could you help with a Python iterator?
Hello! There was a need to include an iterator in your code, but I just ran into a problem. To begin with, I will show the code, then I will try to describe what I want from it.
#Здесь я делаю итератор из файлов в директории
exel_file = []
for name in glob.glob('converted_dir/*.xlsx'):
wb = load_workbook(name)
list = wb['TDSheet']
exel_file.append(list)
iter_exel_file = iter(exel_file)
#Функция, которая должна получать поочередно значения из файлов, как раз таки это я и хочу реализовать с помощью итератора
def model_name_fun():
result = []
for sheet in iter_exel_file:
for i in range(19, 70):
model_name = sheet.cell(row=i, column=2).value
if model_name is not None:
result.append(model_name)
return result
#Запрос по Google API, который в моем понимании должен передавать значение так же поочередно, а именно: получил значения из первого файла - передал, получил и так далее
values = service.spreadsheets().values().batchUpdate(
spreadsheetId=spreadsheet_id,
body={
"valueInputOption": "USER_ENTERED",
"data": [
{"range": (name_position),
"majorDimension": "COLUMNS",
"values": [model_name_fun()]},]} ).execute()
Answer the question
In order to leave comments, you need to log in
With indents and formatting in general - complete hell, nothing is clear and few people want to disassemble this mess.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question