Issue
I'm having an issue with Panda where its prints the whole date frame multiple times, causing it to slow down and along with that, it prints out the incorrect information when being requested to print out 1 specific item
I'm trying to get 'ETA' to print along with the Customer Names in the same order. I have a Excel Spreadsheet but am unable to match the requested name with the requested ETA. I.e. "WILLIAM KLEIN" "10/12/21" "ROGER FRY" "10/13/21"
is what I want. What I get is "WILLIAM KLEIN" "10/12/21" "ROGER FRY" "10/12/21"
Ect ect, until the next iteration "WILLIAM KLEIN" "10/13/21" "ROGER FRY" "10/13/21"
import pandas as pd
desired_width = 500
workbook = pd.read_excel('jobs2.xlsx', sheet_name="Sheet1") # Set up for the excel sheet
# region Setting Console Boundaries
pd.set_option('display.max_columns', 100)
pd.set_option('display.max_rows', 100)
pd.set_option('display.expand_frame_repr', False)
pd.set_option('max_colwidth', -1)
# endregion
# Setting Value for two weeks out if job is more than two weeks out.
twoWeeksOuts = "25,8,2021"
# Getting information from the Excel Sheet
customerName = workbook["Customer Name"]
eta = workbook["ETA"]
for x in eta:
print("PROACTIVE CONTACT TASK: Called " + customerName + " to advise of ETA of product for " + x.strftime("%b %d %Y") + " and that we are still on schedule. Advised Independent PROvider will contact them within two business days of when product is available for installation.")
It prints out 100's of iterations of the same information just with the date changed to match that iteration, which is not by design. I can't even post an example because its so many iterations of different names, same dates. Please assist!
Solution
Rather than trying to get the info from sheet directly to the print()
function, had the sheet move the information to two separate arrays. One for each workbook column:
# Generate workbooks for Customer Name and ETA
customerName = workbook["Customer Name"]
eta = workbook["ETA"]
# Array creation for storing from both types
customerNameArr = [""]
etaArr= [""]
# For each item in range of 85(Size of Sheet) append to previously created arrays
# 0+X to get rid of blank values created by arrays
for x in range(85):
customerNameArr.append(customerName.iloc[0+x])
for x in range(85):
etaArr.append(eta.iloc[0+x])
for x in range(85):
print(customerNameArr[0+x]+" "+str(etaArr[0+x])
Answered By - Billys Tutorial
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.