71456 BUCKET 8/01/2024
666654 VALVE
90000 TYRE
I have the aforementioned content available in a Excel sheet. I would like to store the information in a list, but ONLY when the last column mentions a date.
The script doesn't work properly as unnessary rows without content in the last column are being stored in the list.
I have noticed that the previous value from the last colum was passed to it. Can anyone help me?
Here's my code so far:
import xlrd
excel = "stock.xls"
from datetime import datetime, date
import pandas as pd
import numpy as np
#Read Excel
content = xlrd.open_workbook(excel)
#get content
sheet_brussels = content.sheet_by_index(0)
tools_brussels = []
startdate = date(2022, 1, 1)
#Brussels
for w in range (sheet_brussels.nrows):
if ( w >= 1):
part = sheet_brussels.cell_value(w, 0)
last_sale_date = sheet_brussels.cell_value(w, 7)
print(last_sale_date)
if last_sale_date != "" or last_sale_date != 0:
try:
datetime_date = xlrd.xldate_as_datetime(last_sale_date, 0)
date_object = datetime_date.date()
except:
pass
if part not in tools_brussels and date_object >= startdate:
tools_brussels.append(part)
print(tools_brussels)
I can't figure out how to skip the last colum when this does not mention any date.