Hello. Brand new to python. Inherited the below logic from previous staff member. It does not parse out the PoNo field at all. I need the PoNo field to parse. Can anyone please help??? Absolutely apologies for my ignorance.
The XML file looks like this.
The Python logic used to parse where the parsing of the PoNo is not working:
from importlib.resources import contents
import pandas as pd
import itertools
from bs4 import BeautifulSoup as b
with open(“C:/AutoCrib WebServices/XML Files/ATC/OpenPOs.xml”, “r”) as f: # opening xml file
content = f.read()
soup = b(content, “lxml”)
PoNo = [ values.text for values in soup.findAll(“pono”)]
Line = [ values.text for values in soup.findAll(“line”)]
TagNo = [ values.text for values in soup.findAll(“tagno”)]
VendorID = [ values.text for values in soup.findAll(“vendorid”)]
ItemID = [ values.text for values in soup.findAll(“itemid”)]
ItemRFID = [ values.text for values in soup.findAll(“itemrfid”)]
Station = [ values.text for values in soup.findAll(“station”)]
Bin = [ values.text for values in soup.findAll(“bin”)]
OrderQty = [ values.text for values in soup.findAll(“orderqty”)]
Received = [ values.text for values in soup.findAll(“received”)]
ReceivedBurn = [ values.text for values in soup.findAll(“receivedburn”)]
PackQty = [ values.text for values in soup.findAll(“packqty”)]
UnitCost = [ values.text for values in soup.findAll(“unitcost”)]
UnitPrice = [ values.text for values in soup.findAll(“unitprice”)]
OrderDate = [ values.text for values in soup.findAll(“orderdate”)]
DueDate = [ values.text for values in soup.findAll(“duedate”)]
PromiseDt = [ values.text for values in soup.findAll(“promisedt”)]
ReceiveDt = [ values.text for values in soup.findAll(“receivedt”)]
Processed = [ values.text for values in soup.findAll(“processed”)]
data = [item for item in itertools.zip_longest(PoNo, Line, TagNo, VendorID, ItemID, ItemRFID, Station, Bin, OrderQty, Received, ReceivedBurn, PackQty, UnitCost, UnitPrice, OrderDate, DueDate, PromiseDt, ReceiveDt, Processed)]
df = pd.DataFrame(data=data)
df.to_csv(“C:/AutoCrib WebServices/CSV Files/ATC/OpenPOs.csv”,index=False, header=[‘PoNo’, ‘Line’, ‘TagNo’, ‘VendorID’, ‘ItemID’, ‘ItemRFID’, ‘Station’, ‘Bin’, ‘OrderQty’, ‘Received’, ‘ReceivedBurn’, ‘PackQty’, ‘UnitCost’, ‘UnitPrice’, ‘OrderDate’, ‘DueDate’, ‘PromiseDt’, ‘ReceiveDt’, ‘Processed’])