Good Afternoon, Python Newb here. I'm trying to return a list of customer information that has been scraped from a text file. I need the output to be in a Name, Account Number, Date format. My initial though thought is,
scrape data create list Print by index_number e.g. (Name 1, Account Number 1, Date 1)
Unfortunately, this doesn't work because the list will print out with all the names, then all the Account Numbers, then the date(s). I need the list to print out as name, account number, date.
I'm pretty sure this is because of the way I have the loop running. Below is the code I have been working on.
import re
fin = open(destFileLoc,"r")
text = fin.read()
nameMatch = re.findall(r'\n\w+\s+\w+\s\w+', text)
# for i in range(len(nameMatch)):
# name = nameMatch # print("Name: " + nameMatch[i])
acctMatch = re.findall(r'\s{4}\d{8}', text)
# for i in range(len(acctMatch)):
# account = acctMatch ##print("Account Num: " + acctMatch[i])
dateMatch = re.findall(r'(\d+/\d+/\d+)', text)
# for i in range(len(dateMatch)):
# date = dateMatch ## print("Date of Service : " + dateMatch[i])
patList = [[nameMatch], [acctMatch], [dateMatch]]
for i in range(patList):
print("====== Name Account Number Date ======\n" + str(nameMatch[i]), str(acctMatch[i]), str(dateMatch[i]))