【问题标题】:Data extraction using c#使用 c# 提取数据
【发布时间】:2020-07-10 02:54:24
【问题描述】:

我想解析pdf并使用c#提取姓名地址联系方式等数据

PDF 数据解析是使用 pdfpig 完成的 任何人都可以建议或帮助数据提取吗? 如何从可用数据中提取准确的键值对。? 提前致谢!!

BajajAllianzGeneralInsuranceCompanyLtd.RegisteredandHeadOffice:GEPlaza,AirportRoad,Yerwada,PuneTranscriptofProposalforPrivateCar-PackagePolicyDearRAJINDERKUMARGUPTA,Wewishtoinformyouthatthecontractunderpolicynumber'OG-17-1104-1801-00011267'hasbeenfinalizedbasedontheinformationanddeclarationgivenbyyou,thetranscriptwhereofismentionedbelow.Youarerequestedtoreconfirmthesame.Incaseofanydisagreementorobjectionoranychangeswithrespecttoinformationmentionedbelow,werequestyoutopleaserevertbackwithinaperiodof15daysfromdateofyourreceiptofthis,failingwhichitwillbedeemedthatyouaresatisfiedwiththecorrectnessofthedetailsmentionedbelow.Kindlynotethatasthecontentsanddeclarationscontainedinthistranscriptisthebasisonwhichwehaveissuedthepolicytoyou,weadviseyoutopleaseensurethatyouhaveprovided/disclosedandornotwithheldanymaterialfacts/informationanddeclarations,asPolicybecomesVoidabinitioifmaterialfactsarenotprovided/disclosedandorwithheldandinsuchcasenoclaim,ifany,willbeconsideredbyusapartfromforfeitureofthepremium.Detailsprovidedbyyou:A.Proposerdetails1.ProposerName:RAJINDERKUMARGUPTA2.ProposerAddress:NEARPIPALCHOWK,ASSANDH,,KARNAL,HARYANA-1320393.ProposerMobileNumber:4.ProposerResidentialNumber:NA5.Proposere-mailid:NA6.ProposerProfession:NAB.VehicleDetailsRegistrationNumberMonth/YearofRegnVehicleMakeVehicleModelVehicleSubTypeCubicCapa-cityFuelTypeYearofMan-ufactureSeatingCa-pacityHR40A4511OCT/2004MARUTIALTOSTANDARD796Petrol20045EngineNumberChassisNumberVehicleIDV(inRs.)ElectricalAccessoriesIDV(inRs.)Non-ElectricalAccessoriesIDV(inRs.)CNG/LPGUnit(Extrafitted)IDV(inRs.)TotalIDV(inRs.)0109910973478100000081000C.Coverageopted1.PeriodofInsurance:From20-OCT-201600:01(Hrs)To19-OCT-2017Midnight2.IsyourvehiclefittedwithexternalLPG/CNGkit:No.3.ElectricalAccessoriescoverOpted(IfApplicable):No.4.Non-ElectricalAccessoriescoverOpted(IfApplicable)::No.5.IsVoluntaryExcessopted:No.Amountofvoluntaryexcessopted:Rs.NA.6.WhetherPAcoverisoptedforowner-driver:Yes.7.Isanyadditionalcompulsorydeductibleimposedandagreedupon:No.Amountofadditionalcompulsorydeductibleimposed:NA.8.Whethergeographicalareaextensionisopted:No.DetailsofCountriestowhichgeographicalareaextensioncoverisgiven:NA.9.IsLLtopersonforPaiddriver/Operation/Maintenanceopted:Yes.10.WhetherPAcoverisoptedforpaiddriverotherthanownerdriver:No.SumInsuredforPaidDriver:Rs.NA.11.WhetherPAcoverisoptedforpassengers:No.SumInsuredperPassenger:Rs.NA.12.IsTPPDrestrictedtostatutorylimitofRs.6000?:No.13.PreExistingdamagesinthevehicle:CostofRepair/ReplacementtowardsthedamagedpartsnoticedduringtheinspectionofyourvehiclepriortoenrolmentunderthispolicyasperInspectionreportreferencenumber2016-02305432dulysignedbyyouoryourrepresentativeaswellasthephotographsshallbeexcludedintheeventofanyfutureclaims.14.PremiumforLiabilitycoverage,quotedandagreeduponis:Rs.2205.15.PremiumforODcoverage,quotedandagreeduponis:Rs.861.16.TotalPremium(excludingServiceTaxandEducationCess)forLiabilityandODcoverages,quotedandagreeduponis:Rs.306617.NCB(NoClaimBonus)claimedbyyouandgrantedbyusbasedonyourdeclarationofnoclaimduringyourpreviouspreviouspolicy:-50%.18.Aboutthelastinsurancecompany(i)InsuranceProvider:IFFCOTokioGeneralInsuranceCompanyLimited..(ii)PreviousPolicyNo:1-3S5LBHC,PreviousPolicyExpiryDate:01-SEP-1619.WhetheryourvehicleisHypothecatedandifsothedetailsofPledgeewhosenameisregisteredbyus:No.NameofPledgee:NA.20.AddonCover(s)opted:No.Planname:NAPleasenoteCoverNoteNo.DY1303078914/19-OCT-201610:20issuedtoyoubasingontheaboveinformation.IncaseofDisagreementorobjectionoranychangeswithrespecttoinformationandcontentsmentionedhereinabove,pleasecontactourtollfreenumber&registeryourobjections/changes/disagreementtothecontentsofthistranscriptoryoumayalsosendusemailorwrittencorrespondenceatthefollowingdetailswithinaperiodof15daysfromdateofyourreceiptofthistranscriptalongwithPolicy:I/WeherebyunconditionallyallowtheCompanytoshareallmy/ourinformationbeingcollectedinthisproposalformorthroughtelephonic/email/web-inputsmeansorothermeans,asupdatedfromtimetotimewithingroupentities.TollfreeNumber:1800-22-5858,1800-102-5858,1800-209-5858Emailaddress:customercare@bajajallianz.co.inWebsite:www.bajajallianz.comContactourpolicyservicingbranchat:BlockNo-4,7thFloor,DLFTowers,,15,ShivajiMarg,,-,NewDelhi-110015PH:011-66278000.♦♣♠

我想提取 ProposerName

【问题讨论】:

  • 让我明白,您可以成功地将 pdf 转换为文本,现在您要提取数据吗?好吧,这取决于您的最终文本文件的外观。您可以使用正则表达式模式,或者如果它具有 .csv 格式或其他格式,您可以将文本拆分为行(通过“\n”),然后按列拆分每一行。视情况而定。
  • 如果你还没有做,你可以使用pdftotext将它转换成文本xpdfreader.com/pdftotext-man.html然后你提取数据。
  • 我已经更新了问题描述。这是一种选择 ProposerName 及其值的方法。
  • 我昨天已经回答了:D 刚刚修复了regexPattern 字符串中的一些细节。试试看!

标签: c# pdf extract data-extraction pdf-extraction


【解决方案1】:

看看这段字符串: Proposerdetails1.ProposerName:RAJINDERKUMARGUPTA2.ProposerAddress:NEARPIPALCHOWK

你看到<Key>:<Value>. 中的ProposerName:RAJINDERKUMARGUPTA2. 模式了吗?

你想要的是从文本中找到这个特定的键/值对并取值。

您可以使用Regular Expressions (Regex)

//Imagine that your data is stored here in 'fullText'
public static string GetProposerName(string fullText)
{

   /* Here's the regex filter for us to find a piece of string in the data with the 
    * key ProposerName, some value that we don't know yet and a . termnation.
    * Now take a look in the content inside the (). 
    * This is a group. The symbols between it means that we
    * want to get everything, any content, that is there inside the group. */
   string regexPattern = "ProposerName:(.*?)\\.";

   //Use this classes from System.Text.RegularExpressions
   Match match = Regex.Match(fullText, regexPattern);

   //Important test, it may not find anything...
   if (!match.Success) return null;

   /* If your code reaches here means that you've find the pattern inside the text.
    * Now you take only the value inside the group as a string and voila!*/
   string proposerName = match.Groups[0].Value;

   return proposerName;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-03
    • 2016-10-18
    相关资源
    最近更新 更多