简体   繁体   中英

Extracting Data from Text file in C#

I am trying to extract data from .txt file. I need to extract Group Number,Subscriber Id,Name and Address (your network) from different .txt files.

The data in the text files are extracted using flexireader ocr from an insurance cards

sample Text file 1:
---------------------
Subscriber ID: AH0002305 
PAUL KELLERMAN
Medical plan: PPO 
Group number: L16788344 
Allied 
Pharmacy benefit: CVS Caremark 
RXBIN: 004336 
RXPCN: ADV 
RXGRP: RX4219 
ORX mail order: 
855.566.8393 
Pharmacy help desk: 
800.364.6331 
a remark.com 

Sample Text file 2:
----------------------
 • 
'11, • 
cStarmark 
A Morn, a k ompam 
Employee 
Member: JOHN ABRUZZ 
ID: 3780-1290 Mem Eff: 09/01/2016 
Group ID: MF873078E 
Employer: MINDFLOW 
INC 
Copay: OV $40 \ UC $85 \ ER $500 
Ded: $3000 \ $6000 Fam Ded: $6000 \ $12000 
Coins: 80% \ 60% 
Claims Submission 
Aetna partopa ing 
EDI: 61425 
Mail: Starmark 
P.O. Box 2942 
Clinton, IA 52733-2942 
• • t. doctors and hospitals are independent 
providers and are neither agents nor employees of Aetna. 
Self-funded Plan Administered by Starmark 
llr 
Pharmacy Vendor 
CVS/caremark 
877-876-7217 
RxID: 32149890C 
RxBIN: 004336 
RxPCN: ADV 
RxGRP: RX0022 
ISSUER: 80840 
Ded: $0 Copay: $15 \ $45 \ $75 
Medical PPO Network 
Aetna Signature 
Administrators' PPO 
By aetna 
To locate a PPO provider: 
 www.aetna.com/asa 
 800-522-1246 

Main problem for me is , in one file it is subscriber ID , other file it is mentioned as Member ID, How can i considered them as same , Can any one can help me with this. I am a intern developer, I don't have much experience on C#.

I tried this code but it is matching the pattern

    class Program
    {
        static void Main(string[] args)
        {
            string path = @"C:\Users\Kumar\Desktop\Insurance text\Previous.out.txt";
            StringBuilder buffer = new StringBuilder();
            using (StreamReader sr = new StreamReader(path))
            {
                while (sr.Peek() >= 0)
                {
                    String str = sr.ReadLine();
                    if (Regex.IsMatch(str, "Subscriber ID"))
                        buffer.Append(str + "\n");  
                }
            }
            Console.WriteLine(buffer.ToString());
             Console.ReadLine();
    }
}

in one file it is subscriber ID , other file it is mentioned as Member ID, How can i considered them as same

One would write a mapping function, but consider the data as just an id and then associate the data in the main program after reading in the entities , and storing both variables.

I am trying to extract data from .txt file. I need to extract Group Number,Subscriber Id,Name and Address (your network) from different .txt files.

You will need to write two different processes to extract the data. Using two different regular expressions for each one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM