I have to parse a formatted pdf to get some feilds. The PDF is here. What I need to parse is shown in this imgur. I have used PyPDF2 to get text, But It returns raw text without any formatting.
import PyPDF2
pdfFileObj = open('GPO-PLUMBOOK-2000-4-1.pdf','rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
pageObj = pdfReader.getPage(0)
print(pageObj.extractText())
Output I got is as follows:
LEGISLATIVE BRANCHLocationPosition TitleName of IncumbentPayPlanType ofAppt.Level,Grade, orPayTenureExpiresARCHITECT OF THE CAPITOLAlan M. HantmanWashington, DCArchitect of the Capitol10 years02/02/07IIIEXPASLocationPosition TitleName of IncumbentPayPlanType ofAppt.Level,Grade, orPayTenureExpiresGENERAL ACCOUNTING OFFICEDavid M. WalkerWashington, DCComptroller General of the United States11/09/1315 years$141,300OTPASVacant Do...........Deputy Comptroller General of the United States..................OTXSLocationPosition TitleName of IncumbentPayPlanType ofAppt.Level,Grade, orPayTenureExpiresGOVERNMENT PRINTING OFFICEMichael F. DiMarioWashington, DCPublic Printer............IIIEXPASRobert T. Mansker Do...........Deputy Public Printer............IVEXXSFrancis J. Buckley, Jr. Do...........Superintendent of Documents..................SLXSRobert G. Andary Do...........Inspector General..................SLXSMary Beth Lawler Do...........Staff Assistant............14OTSCLocationPosition TitleName of IncumbentPayPlanType ofAppt.Level,Grade, orPayTenureExpiresLIBRARY OF CONGRESSLIBRARIAN OF CONGRESSJames H. BillingtonWashington, DCLibrarian of Congress............IIIEXPASLIBRARY OF CONGRESS TRUST FUND BOARDJames H. Billington Do...........Chairman (Ex-Officio)..................WCPASTed Stevens Do...........Chairman of the Joint Committee of the Library (Ex-Officio)..................WCXSLawrence Summers Do...........Member (Ex-Officio), Secretary of the Treasury..................WCPASDonald Hammond Do...........Member (Designee for the Secretary of the Treasurer)..................WCXSCeil Pulitzer Do...........Member5 years03/23/03......WCPASNajeeb Halaby Do...........Member5 years08/31/05......WCPASJohn Kluge Do...........Member5 years03/10/03......WCXSWayne Berman Do...........Member5 years12/22/01......WCXSEdwin Cox Do...........Member5 years03/31/04......WCXSJohn Henry Do...........Member5 years12/22/03......WCXSDonald Jones Do...........Member5 years10/08/02......WCXSJulie Finley Do...........Member5 years06/29/01......WCXSBernard Rappaport Do...........Member5 years12/22/01......WCXS(1)
I need to separate the data e.g Data under Location
column and so on.