Solved

Code not working

Posted on 2016-09-02
7
67 Views
Last Modified: 2016-09-07
$find = '.5010.';

$dirname = '79';
if(!is_dir($dirname))
    mkdir($dirname, 0777);

$directory_with_files = './';
$dh  = opendir($directory_with_files);
$files = array();
while (false !== ($filename = readdir($dh)))
{
    if(in_array($filename, array('.', '..')) || is_dir($filename))
        continue;

    $files[] = $filename;
}


foreach($files as $file)
{
    //find only 5010 files
    if(stripos($file, $find) !== false)
    {
        // open the 5010 file
        $handle = fopen($file, "r");
        $file_content = file_get_contents($file);
     
        
        if ($handle) {
            $header = '';
            $footer = '';
            $payor_blocks = array();
            
            
            // determine if file has more than one payor
            $payor_count = substr_count($file_content, 'N1);
            //if the file has more than one payor
            if($payor_count > 1) {
                //read the file line by line
                $header_end = false;
                $block_start = false;
                $count = 1;
 //payor_count outputs: 5
 //header_end and block_start prints out nothing
           
                
                while (($line = fgets($handle)) !== false) {
                    //look for the first payor block
                    if(strpos($line, 'N1') !== false || $block_start) {
                        $header_end = true; $block_start = true;
                        //see if the block finished
                        if(strpos($line, 'CAS') !== false) {
                            $block_start = false;
                            $payor_blocks[$count] = $line;
                            $count++;
                        }
                        $payor_blocks[$count] = $line;
                    } else {
                        //append to the header
                        if($header_end) {
                            $footer .= $line."\n";
                        } else {
                            $header .= $line."\n";

                        }
                    }
                }
                
                
                //get payor blocks and create a file foreach payor
                $new_files = array();
                foreach($payor_blocks as $block) {
                    $filename = '';
                    $new_files[] = array(
                        'name' => $filename,
                        'content' => $header."\n".$block."\n".$footer
                    );
//footer prints out after the first CAS and all the rest
                }
                echo "<pre>" . print_r($new_files, true) . "</pre>";
                //loop through new files and create them
                foreach($new_files as $new_file) {
                    //create file
                	$myfile = fopen("$file", "x");
                    //put contents in the file
                	//$txt = $new_file; 
//new file prints nothing                	
                	fwrite($myfile, "{$new_file['content']}");	
              		//close the file
                	fclose($myfile);
                }
                
            } else {

            	// DO what u were doing in script #1
           while (($line = fgets($handle)) !== false)
            {
            	$refid = 'REF';
            	
            	if(stripos($line, $refid) !== false)
            	{
            		$refnumber = str_replace(array($refid, '~'), array('', ''), $line);
            		$refnumber = trim($refnumber);
            	
            		if($refnumber != '')
            		{
            			$refnumber = '_'.$refnumber.'_';
            			$filerenamed = str_replace($find, $refnumber, $file);
            			copy($file, $dirname.'/'.$filerenamed);
            		}
            		echo $refnumber . "\n";
            	}
            	}
            	 
            }
        }
        // DONE - close the file
        fclose($handle);
    }
}

Open in new window


My code above doesnt print new_files after it goes inside the foreach loop and doesnt print block
My input:
ISA*00*          *00*          *ZZ*1332274      *ZZ*361550      *160901*0117*^*00501*000iopjiopiop25488*0*P*:~
GS*HP*1332274*362931550901*0117*1*X5010X221A1~
ST*835*0001~
BPR*uhiuoH*0*C*NON************20160901~
TRN*1*4932528*1351uoip840597~
REF*EV*75000~
DTM*405*20160831~
N1*PR*NATIONAL, INC.~
N3*PO BOX 6475~
N4*INDIOLIIN*462066475~
REF*2U*SL0~
N1*PE*TOUSSAINT G TOOLE, MD,SC*XX*1356356232~
N3*5501W 79TH ST 400~
N4*BURBANK*IL*604592190~
REF*TJ*362958628~
LX*1~
CLP*135001-10304931*1*142*0**MB*0216239336590*11*1~
NM1*QC*1*CHEARS*JERRILYNN*J***HN*346341418B~
NM1*82*1******XX*1568458503~
MOA***MA01~
DTM*050*20160826~
SVC*H210**0**1~
DTM*20150616~
CAS*CO*29*90~
REF*LU*11~
REF*6R*EP082516756261046-01~
LQ*HE*N211~
SVC99212:25:AQ*52*0**0**1~
DTM*472*20150616~
CAS*CO*29*52~
REF*LU*11~
REF*6R*EP082516756261046-02~
LQ*HE*N211~
CLP*135001-10299192*1*85*0*85*MB*0216239336860*11*1~
NM1*QC*1***HN*587646953A~
NM1*82****XX*1689659583~
MOA***MA01~
DTM*050*20160826~
SVC*HC2591:AQ*85*0**0**1~
DTM*472*20160811~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261334-01~
CLP*135001-10410032*1*372*0*372*MB*0216243397090*11*1~
NM1*Q**HN*333384442C1~
NM1*82*11568458503~
MOA***MAMA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*HC:99202:25:AQ*120*0**0**1~
DTM*472*21117~
CAS*PR*31*120~
REF*LU*11~
REF*6R*EP082916765983343-01~
SVC*HC:69200:AQ*100*0**0**1~
DTM*472*20151117~
CAS*PR*31*100~
REF*LC:99213:AQ*100*0**0**1~
DTM*472*20151124~
CAS*PR*31*100~
REF*LU*11~
REF*6R*EP082916765983343-03~
SVC*HC:99212:AQ*52*0**0**1~
DTM20151215~
CAS*PR*31*52~
REF*LU*11~
REFR*EP082916765983343-04~
CLP*01-10410032*1*52*0*52*MB*0216243397092*11*1~
NM1*QDGES*DOMINIQUE****HN*333384442C1~
NM1*82*****XX*1568458503~
MOA***MA01*MA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*H9212:AQ*52*0**0**1~
DTM*472*20160308~
CAS*PR*31*52~
REF11~
REF*6R*EP082916765983343-05~
CLP5001-10410032*1*85*0*85*MB*0216243397220*11*1~
NM1*QC*1*HODGES*DOMINIQUE****HN*333384442C1~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM*036*20140630~
DTM0*20160830~
SVC*HC:92557:AQ*85*0**0**1~
DTM*472*20151215~
CAS*PR*31*85~
REF*LU*11~
REF*6R*EP082916765983367-01~
CLP*135001-10298522*1*85*0*85*MB*0216239336840*11*1~
NM1*QC*1*JACKSON*ANNIE****HN*425482465D~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM0*20160826~
SVC*H:*85*0**0**1~
DTM*472*20150430~
CAS*PR*204*85~
REF*LU*11~
REF*6EP082516756261044-01~
CLP*135001-10409217*1*85*0*85*MB*0216239336970*11*1~
NM1*QC*1*WALDON*THERRELL****HN*335541703A~
NM1*82*1******XX*1689659583~
MOA**A01~
DTM*050*20160826~
SVC*HC:92591:AQ*85*0**0**1~
DTM*472*20151029~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261336-01~
SE*112*0001~
ST*8*0002~
BPR*I*351.88*C*ACH*CCP*01*042000013*DA*152302017834*1351840597**01*071000013*DA*136156290*20160901~
TRN*1891234746*1351840597~
REF*EV*75000~
DTM*405*20160831~
N1NATIONAL~
N3*POOX 6475~
N4*INDIAN*IN*462066475~
REF*2U*SL0~
REF*6R*EP0816729045276-01~
AMT*B6*112.45~
LQ*HE700~
*HE*99~
CLP*135001-10424597*19*295*162.78*41.53*MB*0216231279150*11*1~
NM1*QC*1*LON*WALTER****HN*425808029A~
NM1*82*1*****XX*1568458503~
NM1*T2*HCSC-BCBS OF IL,OTHER B ONLY*****PI*00041~
MOA***1*MA18~
DTM*0501618~
SVC*HC:203:25:AQ*120*88.16**1~
DTM*472*20160804~
CAS**2*22.49~
REF*L11~
REFR*EP081716729045275-01~
AMT*B6*112.45~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:G0268:AQ*90*44.53**1~
DTM*472*20160804~
CAS*CO5*.86**237*2.34**253*.91~
CASR*2*11.36~
RELU*11~
REF*6R*EP081716729045275-02~
AMT*B6*56.8~
LQ*HE*N700~
LQ*HE699~
SVC*HC:92557:AQ*85*30.09**1~
DTM*472*20160804~
CAS**4*45.04**237*1.58**253*.61~
CAS*PR*7.68~
REF*LU*11~
REF*6R*EP081716729045275-03~
AMT*B68.38~
LQ*HE*N700~
LQ*HE*N699~
CL01-10424587*19*190*100.94*25.75*MB*0216231279030*11*1~
NM1*1*SH*MICHAEL****HN*353627320A~
N568458503~
NM1*TT*2*IL FA****PI*70009~
MOA*7~
DTM*050*20160818~
SVC*HC:99202:25:AQ*100*60.3**1~
DTM*472*20160804~
CAS*CO*45*19.92**237*3.17**253*1.23~
CAS*PR*2*15.38~
REF*LU*11~
16729045274-01~
AMT*B6*76.91~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:69210:AQ*90*40.64**1~
DTM*472*20160804~
CAS*CO*45*36.02**237*2.14**253*.83~
CAS*PR*2*10.37~
REF*LU*11~
REF*6R*EP081716729045274-02~
AMT*B6*51.84~
LQ*HE*N700~
LQ9~
SE*89*0002~
ST*835*0003~
BPR*H*NON************20160901~
TRN*1*493002517*1351840597~
REF*EV*75000~
DTM*405*20160831~
CAS
REF*12~
REF*6R*E1441-01~
LQ*HE*N572~
CLP*216237382210*12*1~
NM1*QC*1*8249037A~
NM1*82*****XX*1538317557~
MOA***MA01~
DTM*0500160824~
SVC*H:96:GP:59*50*0**0**1~
DTM*472*260216~
CAS*OA*18*50~
REF*LU*12~
REF*6R*EP08247518381-01~
SE*382*0005~
GE*5*1~
IEA*1*0088~

Open in new window


My Output:

ISA*00*          *00*          *ZZ*1332274      *ZZ*361550      *160901*0117*^*00501*000iopjiopiop25488*0*P*:~
GS*HP*1332274*362931550901*0117*1*X5010X221A1~
ST*835*0001~
BPR*uhiuoH*0*C*NON************20160901~
TRN*1*4932528*1351uoip840597~
REF*EV*75000~
DTM*405*20160831~
---///////////////no N1s
CAS
REF*12~
REF*6R*E1441-01~
LQ*HE*N572~
CLP*216237382210*12*1~
NM1*QC*1*8249037A~
NM1*82*****XX*1538317557~
MOA***MA01~
DTM*0500160824~
SVC*H:96:GP:59*50*0**0**1~
DTM*472*260216~
CAS*OA*18*50~
REF*LU*12~
REF*6R*EP08247518381-01~
SE*382*0005~
GE*5*1~
IEA*1*0088~

Open in new window

0
Comment
Question by:Jasmine Ikhreishi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 41781780
0
 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41781791
Test data:
ISA*00*          *00*          *ZZ*1332274      *ZZ*361550      *160901*0117*^*00501*000iopjiopiop25488*0*P*:~
GS*HP*1332274*362931550901*0117*1*X5010X221A1~
ST*835*0001~
BPR*uhiuoH*0*C*NON************20160901~
TRN*1*4932528*1351uoip840597~
REF*EV*75000~
DTM*405*20160831~
N1*PR*NATIONAL, INC.~
N3*PO BOX 6475~
N4*INDIOLIIN*462066475~
REF*2U*SL0~
N1*PE*TOUSSAINT G TOOLE, MD,SC*XX*1356356232~
N3*5501W 79TH ST 400~
N4*BURBANK*IL*604592190~
REF*TJ*362958628~
LX*1~
CLP*135001-10304931*1*142*0**MB*0216239336590*11*1~
NM1*QC*1*CHEARS*JERRILYNN*J***HN*346341418B~
NM1*82*1******XX*1568458503~
MOA***MA01~
DTM*050*20160826~
SVC*H210**0**1~
DTM*20150616~
CAS*CO*29*90~
REF*LU*11~
REF*6R*EP082516756261046-01~
LQ*HE*N211~
SVC99212:25:AQ*52*0**0**1~
DTM*472*20150616~
CAS*CO*29*52~
REF*LU*11~
REF*6R*EP082516756261046-02~
LQ*HE*N211~
CLP*135001-10299192*1*85*0*85*MB*0216239336860*11*1~
NM1*QC*1***HN*587646953A~
NM1*82****XX*1689659583~
MOA***MA01~
DTM*050*20160826~
SVC*HC2591:AQ*85*0**0**1~
DTM*472*20160811~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261334-01~
CLP*135001-10410032*1*372*0*372*MB*0216243397090*11*1~
NM1*Q**HN*333384442C1~
NM1*82*11568458503~
MOA***MAMA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*HC:99202:25:AQ*120*0**0**1~
DTM*472*21117~
CAS*PR*31*120~
REF*LU*11~
REF*6R*EP082916765983343-01~
SVC*HC:69200:AQ*100*0**0**1~
DTM*472*20151117~
CAS*PR*31*100~
REF*LC:99213:AQ*100*0**0**1~
DTM*472*20151124~
CAS*PR*31*100~
REF*LU*11~
REF*6R*EP082916765983343-03~
SVC*HC:99212:AQ*52*0**0**1~
DTM20151215~
CAS*PR*31*52~
REF*LU*11~
REFR*EP082916765983343-04~
CLP*01-10410032*1*52*0*52*MB*0216243397092*11*1~
NM1*QDGES*DOMINIQUE****HN*333384442C1~
NM1*82*****XX*1568458503~
MOA***MA01*MA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*H9212:AQ*52*0**0**1~
DTM*472*20160308~
CAS*PR*31*52~
REF11~
REF*6R*EP082916765983343-05~
CLP5001-10410032*1*85*0*85*MB*0216243397220*11*1~
NM1*QC*1*HODGES*DOMINIQUE****HN*333384442C1~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM*036*20140630~
DTM0*20160830~
SVC*HC:92557:AQ*85*0**0**1~
DTM*472*20151215~
CAS*PR*31*85~
REF*LU*11~
REF*6R*EP082916765983367-01~
CLP*135001-10298522*1*85*0*85*MB*0216239336840*11*1~
NM1*QC*1*JACKSON*ANNIE****HN*425482465D~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM0*20160826~
SVC*H:*85*0**0**1~
DTM*472*20150430~
CAS*PR*204*85~
REF*LU*11~
REF*6EP082516756261044-01~
CLP*135001-10409217*1*85*0*85*MB*0216239336970*11*1~
NM1*QC*1*WALDON*THERRELL****HN*335541703A~
NM1*82*1******XX*1689659583~
MOA**A01~
DTM*050*20160826~
SVC*HC:92591:AQ*85*0**0**1~
DTM*472*20151029~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261336-01~
SE*112*0001~
ST*8*0002~
BPR*I*351.88*C*ACH*CCP*01*042000013*DA*152302017834*1351840597**01*071000013*DA*136156290*20160901~
TRN*1891234746*1351840597~
REF*EV*75000~
DTM*405*20160831~
N1NATIONAL~
N3*POOX 6475~
N4*INDIAN*IN*462066475~
REF*2U*SL0~
REF*6R*EP0816729045276-01~
AMT*B6*112.45~
LQ*HE700~
*HE*99~
CLP*135001-10424597*19*295*162.78*41.53*MB*0216231279150*11*1~
NM1*QC*1*LON*WALTER****HN*425808029A~
NM1*82*1*****XX*1568458503~
NM1*T2*HCSC-BCBS OF IL,OTHER B ONLY*****PI*00041~
MOA***1*MA18~
DTM*0501618~
SVC*HC:203:25:AQ*120*88.16**1~
DTM*472*20160804~
CAS**2*22.49~
REF*L11~
REFR*EP081716729045275-01~
AMT*B6*112.45~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:G0268:AQ*90*44.53**1~
DTM*472*20160804~
CAS*CO5*.86**237*2.34**253*.91~
CASR*2*11.36~
RELU*11~
REF*6R*EP081716729045275-02~
AMT*B6*56.8~
LQ*HE*N700~
LQ*HE699~
SVC*HC:92557:AQ*85*30.09**1~
DTM*472*20160804~
CAS**4*45.04**237*1.58**253*.61~
CAS*PR*7.68~
REF*LU*11~
REF*6R*EP081716729045275-03~
AMT*B68.38~
LQ*HE*N700~
LQ*HE*N699~
CL01-10424587*19*190*100.94*25.75*MB*0216231279030*11*1~
NM1*1*SH*MICHAEL****HN*353627320A~
N568458503~
NM1*TT*2*IL FA****PI*70009~
MOA*7~
DTM*050*20160818~
SVC*HC:99202:25:AQ*100*60.3**1~
DTM*472*20160804~
CAS*CO*45*19.92**237*3.17**253*1.23~
CAS*PR*2*15.38~
REF*LU*11~
16729045274-01~
AMT*B6*76.91~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:69210:AQ*90*40.64**1~
DTM*472*20160804~
CAS*CO*45*36.02**237*2.14**253*.83~
CAS*PR*2*10.37~
REF*LU*11~
REF*6R*EP081716729045274-02~
AMT*B6*51.84~
LQ*HE*N700~
LQ9~
SE*89*0002~
ST*835*0003~
BPR*H*NON************20160901~
TRN*1*493002517*1351840597~
REF*EV*75000~
DTM*405*20160831~
CAS
REF*12~
REF*6R*E1441-01~
LQ*HE*N572~
CLP*216237382210*12*1~
NM1*QC*1*8249037A~
NM1*82*****XX*1538317557~
MOA***MA01~
DTM*0500160824~
SVC*H:96:GP:59*50*0**0**1~
DTM*472*260216~
CAS*OA*18*50~
REF*LU*12~
REF*6R*EP08247518381-01~
SE*382*0005~
GE*5*1~
IEA*1*0088~

Open in new window


Expected output(file 1):
ISA*00*          *00*          *ZZ*1332274      *ZZ*361550      *160901*0117*^*00501*000iopjiopiop25488*0*P*:~
GS*HP*1332274*362931550901*0117*1*X5010X221A1~
ST*835*0001~
BPR*uhiuoH*0*C*NON************20160901~
TRN*1*4932528*1351uoip840597~
REF*EV*75000~
DTM*405*20160831~
N1 NATIONAL, INC.~
N3*PO BOX 6475~
N4*INDIOLIIN*462066475~
REF*2U*SL0~
N1*PE*TOUSSAINT G TOOLE, MD,SC*XX*1356356232~
N3*5501W 79TH ST 400~
N4*BURBANK*IL*604592190~
REF*TJ*362958628~
LX*1~
CLP*135001-10304931*1*142*0**MB*0216239336590*11*1~
NM1*QC*1*CHEARS*JERRILYNN*J***HN*346341418B~
NM1*82*1******XX*1568458503~
MOA***MA01~
DTM*050*20160826~
SVC*H210**0**1~
DTM*20150616~
CAS*CO*29*90~
REF*LU*11~
REF*6R*EP082516756261046-01~
LQ*HE*N211~
SVC99212:25:AQ*52*0**0**1~
DTM*472*20150616~
CAS*CO*29*52~
REF*LU*11~
REF*6R*EP082516756261046-02~
LQ*HE*N211~
CLP*135001-10299192*1*85*0*85*MB*0216239336860*11*1~
NM1*QC*1***HN*587646953A~
NM1*82****XX*1689659583~
MOA***MA01~
DTM*050*20160826~
SVC*HC2591:AQ*85*0**0**1~
DTM*472*20160811~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261334-01~
CLP*135001-10410032*1*372*0*372*MB*0216243397090*11*1~
NM1*Q**HN*333384442C1~
NM1*82*11568458503~
MOA***MAMA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*HC:99202:25:AQ*120*0**0**1~
DTM*472*21117~
CAS*PR*31*120~
REF*LU*11~
REF*6R*EP082916765983343-01~
SVC*HC:69200:AQ*100*0**0**1~
DTM*472*20151117~
CAS*PR*31*100~
REF*LC:99213:AQ*100*0**0**1~
DTM*472*20151124~
CAS*PR*31*100~
REF*LU*11~
REF*6R*EP082916765983343-03~
SVC*HC:99212:AQ*52*0**0**1~
DTM20151215~
CAS*PR*31*52~
REF*LU*11~
REFR*EP082916765983343-04~
CLP*01-10410032*1*52*0*52*MB*0216243397092*11*1~
NM1*QDGES*DOMINIQUE****HN*333384442C1~
NM1*82*****XX*1568458503~
MOA***MA01*MA15~
DTM*036*20140630~
DTM*050*20160830~
SVC*H9212:AQ*52*0**0**1~
DTM*472*20160308~
CAS*PR*31*52~
REF11~
REF*6R*EP082916765983343-05~
CLP5001-10410032*1*85*0*85*MB*0216243397220*11*1~
NM1*QC*1*HODGES*DOMINIQUE****HN*333384442C1~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM*036*20140630~
DTM0*20160830~
SVC*HC:92557:AQ*85*0**0**1~
DTM*472*20151215~
CAS*PR*31*85~
REF*LU*11~
REF*6R*EP082916765983367-01~
CLP*135001-10298522*1*85*0*85*MB*0216239336840*11*1~
NM1*QC*1*JACKSON*ANNIE****HN*425482465D~
NM1*82*1******XX*1689659583~
MOA***MA01~
DTM0*20160826~
SVC*H:*85*0**0**1~
DTM*472*20150430~
CAS*PR*204*85~
REF*LU*11~
REF*6EP082516756261044-01~
CLP*135001-10409217*1*85*0*85*MB*0216239336970*11*1~
NM1*QC*1*WALDON*THERRELL****HN*335541703A~
NM1*82*1******XX*1689659583~
MOA**A01~
DTM*050*20160826~
SVC*HC:92591:AQ*85*0**0**1~
DTM*472*20151029~
CAS*PR*204*85~
REF*LU*11~
REF*6R*EP082516756261336-01~
SE*112*0001~
ST*8*0002~
BPR*I*351.88*C*ACH*CCP*01*042000013*DA*152302017834*1351840597**01*071000013*DA*136156290*20160901~
TRN*1891234746*1351840597~
REF*EV*75000~
DTM*405*20160831~
CAS
REF*12~
REF*6R*E1441-01~
LQ*HE*N572~
CLP*216237382210*12*1~
NM1*QC*1*8249037A~
NM1*82*****XX*1538317557~
MOA***MA01~
DTM*0500160824~
SVC*H:96:GP:59*50*0**0**1~
DTM*472*260216~
CAS*OA*18*50~
REF*LU*12~
REF*6R*EP08247518381-01~
SE*382*0005~
GE*5*1~
IEA*1*0088~

Open in new window


file(2):
ISA*00*          *00*          *ZZ*1332274      *ZZ*361550      *160901*0117*^*00501*000iopjiopiop25488*0*P*:~
GS*HP*1332274*362931550901*0117*1*X5010X221A1~
ST*835*0001~
BPR*uhiuoH*0*C*NON************20160901~
TRN*1*4932528*1351uoip840597~
REF*EV*75000~
DTM*405*20160831~

N1 NATIONAL~
N3*POOX 6475~
N4*INDIAN*IN*462066475~
REF*2U*SL0~
REF*6R*EP0816729045276-01~
AMT*B6*112.45~
LQ*HE700~
*HE*99~
CLP*135001-10424597*19*295*162.78*41.53*MB*0216231279150*11*1~
NM1*QC*1*LON*WALTER****HN*425808029A~
NM1*82*1*****XX*1568458503~
NM1*T2*HCSC-BCBS OF IL,OTHER B ONLY*****PI*00041~
MOA***1*MA18~
DTM*0501618~
SVC*HC:203:25:AQ*120*88.16**1~
DTM*472*20160804~
CAS**2*22.49~
REF*L11~
REFR*EP081716729045275-01~
AMT*B6*112.45~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:G0268:AQ*90*44.53**1~
DTM*472*20160804~
CAS*CO5*.86**237*2.34**253*.91~
CASR*2*11.36~
RELU*11~
REF*6R*EP081716729045275-02~
AMT*B6*56.8~
LQ*HE*N700~
LQ*HE699~
SVC*HC:92557:AQ*85*30.09**1~
DTM*472*20160804~
CAS**4*45.04**237*1.58**253*.61~
CAS*PR*7.68~
REF*LU*11~
REF*6R*EP081716729045275-03~
AMT*B68.38~
LQ*HE*N700~
LQ*HE*N699~
CL01-10424587*19*190*100.94*25.75*MB*0216231279030*11*1~
NM1*1*SH*MICHAEL****HN*353627320A~
N568458503~
NM1*TT*2*IL FA****PI*70009~
MOA*7~
DTM*050*20160818~
SVC*HC:99202:25:AQ*100*60.3**1~
DTM*472*20160804~
CAS*CO*45*19.92**237*3.17**253*1.23~
CAS*PR*2*15.38~
REF*LU*11~
16729045274-01~
AMT*B6*76.91~
LQ*HE*N700~
LQ*HE*N699~
SVC*HC:69210:AQ*90*40.64**1~
DTM*472*20160804~
CAS*CO*45*36.02**237*2.14**253*.83~
CAS*PR*2*10.37~
REF*LU*11~
REF*6R*EP081716729045274-02~
AMT*B6*51.84~
LQ*HE*N700~
LQ9~
SE*89*0002~
ST*835*0003~
BPR*H*NON************20160901~
TRN*1*493002517*1351840597~
REF*EV*75000~
DTM*405*20160831~
CAS
REF*12~
REF*6R*E1441-01~
LQ*HE*N572~
CLP*216237382210*12*1~
NM1*QC*1*8249037A~
NM1*82*****XX*1538317557~
MOA***MA01~
DTM*0500160824~
SVC*H:96:GP:59*50*0**0**1~
DTM*472*260216~
CAS*OA*18*50~
REF*LU*12~
REF*6R*EP08247518381-01~
SE*382*0005~
GE*5*1~
IEA*1*0088~

Open in new window

0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 41781797
Thanks.  Let me work with that a little bit and I'll try to show you how to bridge the gap!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Jasmine Ikhreishi
ID: 41781799
Alright thank you!
0
 
LVL 22

Expert Comment

by:Kim Walker
ID: 41782477
Line 36 is missing a closing quote mark. it should be:
            $payor_count = substr_count($file_content, 'N1');

Open in new window

1
 
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 250 total points
ID: 41782513
@Ray, feel free to tell me to butt out if I'm intruding.

@Jasmine,

I have a lot of questions but I'd like to take them one at a time.

I'm not sure how you expect to get the results you've posted. I've been looking at your expected results for file 1 which appear to be exact duplicates of the test data for lines 1 - 7 and 9-115. But line 8 does not appear to be in the test data at all and I don't see where you are doing any manipulation of the data to generate that text. Line 8 of the test data could easily be manipulated to generate the desired result, though.

And lines 116-132 do not appear to be in the test data either. Can you explain how you expect these lines to appear in your file 1 output?
2
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 41782871
@Kim, thanks for joining into the dialog; I do not always have time to run these things to ground and I appreciate another set of eyes on the problems.  As it happens, I won't get time to take a careful look at the test data until Tuesday, so anything we can accomplish between now and then (establish rules, explain the data sources, etc) is helpful, appreciated, and may resolve the issues more quickly.

I also think, in spite of the Author's decision not to accept suggestions for E-E Gigs, that this may still be a good candidate for E-E Gigs. You may have seen the similar questions, check the author's profile "history" and see some of the other questions that appear to be working with similar data sets.

1

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question