import os, shutil
from tkinter import * #tkinter stands for toolkit interface
from tkinter import filedialog
import re
import xlwings as xw
file_names = xw.Book(filedialog.askopenfilename())
file_names_sh = file_names.sheets['fe_0.85']
folder_source_train = filedialog.askdirectory()
train_destination = r'D:\Machine_learning\train/'
import numpy as np
numbers= re.compile(r'(\d+)')
def numerical_sort(value):
parts= numbers.split(value)
parts[1::2]= map(int, part[1::2])
return parts
def copy_range(start_col, start_row, end_col, end_row, sheet):
range_selected = []
for i in range(start_row, end_row + 1, 1):
row_selected = []
for j in range(start_col, end_col + 1, 1):
row_selected.append(sheet.cell(row = i, column = j).value)
range_selected.append(row_selected)
return range_selected
selectedRange_train = copy_range(1, 1, 2, 100, file_names_sh)
I encountered error like 'Sheet' object has no attribute 'cell'. There seems to be a problem with "copy_range(~~)" in the code mentioned above. What should I add? I have no idea what or how to fix it. Please help me...
An error of type:
[1]: object has no attribute attr
usually refers to the class not having any specific method implemented with that name, for your case object sheet doesn't have a method cell implemented on it, either the attribute you are looking to use is cells
as per the source code: cells or the specific attribute exists in an older version of xlwings