Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
append in excel
#1
greetings everyone
i am currently trying to insert the data from excel into the array but the output of it only an empty array

Headers_ = []
Values_ = []
for i in range(sheet.nrows):
    if sheet.row_values(i,0) == 'mine':
        Row_list_ =[]
        Row_Val_ =[]
        for j in range(sheet.ncols):
            Row_list_.append(sheet.row_values(i,j))
            Row_Val_.append(sheet.row_values((i+1),j))
        Headers_.append(Row_list_)
        Values_.append(Row_Val_)
print(Values_)
output
[]
Reply
#2
maybe because none of sheet.row_values(i,0) is equal to 'mine'?
if that condition is not true nothing is appended to Values_

btw: please have a look into PEP 8 - Style Guide for Python code
What do you think this _ at the end of your variables does?
Nothing but it makes our eyes scream wtf.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to append a value to specific excel cell using openpyxl hobbyist 0 4,861 Mar-05-2021, 07:14 PM
Last Post: hobbyist
  Append excel sheet using openpyxl TammyP 1 2,391 Feb-02-2021, 06:32 PM
Last Post: nilamo
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 2,597 Apr-22-2020, 01:01 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020