0

List of lists!

Please consider the code below. I am trying to create a list of lists. I extracted the texts code and name from a pdf document of n pages. Each page has it's unique code and name. So I am creating a list of list of names and codes. from fpdf import FPDF from prettytable import PrettyTable import fpdf import PyPDF2 import os.path import textract import re file = raw_input("Enter the file path: ") needfile = file readfile = PyPDF2.PdfFileReader(open(needfile, "rb+")) #open file number_of_pages = readfile.getNumPages() count = readfile.numPages for i in range(count): page = readfile.getPage(i) pdread = page.extractText() readt = re.findall(r'\d+',str(pdread.encode("utf-8"))) be = [] for num in readt: if len(num) == 6: code = num code = str(ippis) splitted = pdread.split() aq = splitted[18] aq2 = splitted[19] aq3 = splitted[20] res = aq3.replace("MISUR", "") name = aq + ' ' + aq2 + ' ' + res name = str(saq) z = [name, code] print (z) I need a result like [[name, code], [name, code]...]

29th Apr 2020, 11:46 AM
Olaleye Moses Abiola
2 Answers
+ 2
Check this question and its related code: it's the quite the same principle but with numbers: https://www.sololearn.com/Discuss/2262595/?ref=app https://code.sololearn.com/ccw6RdhSai9i/?ref=app#py Hope this could help! ;)
29th Apr 2020, 12:26 PM
visph
visph - avatar
+ 1
Thank you visph Found a solution to the problem
29th Apr 2020, 1:10 PM
Olaleye Moses Abiola