PerlSufi has asked for the wisdom of the Perl Monks concerning the following question:
each 200~ indicates the beginning of a statement and each 701~ is the last line of that statement. Each 2 digits following the ~ are not needed. They indicate certain data types and are consistent throughout the whole file. I need pretty much all of these fields for rendering to postscript later on. But first, I need help extracting it in an intelligible way. Below is my slightly altered code so that it can be run by any helpers here:200~020000000123~0509112013~0610102013~07JOHN SMITH~08131 MAIN ST~09SO +MEWHERE TX 77777~12SOMEWHERE~13TX~1477777~15 R011~197~24bobsmithsemail@gmail.com~251` 501~0211.150%~03.030547%` 500~0109112013~020001~03PERSONAL LOAN~05Balance Forward~0694188~0770~0 +87~182~21Original Balance~22138000~24608` 300~01BOBS FRIEND~021` 530~0109182013~0209182013~0312184-~04609~051237~0610338-~0783850~08Pay +ments by Check~23K~25P` 510~0109182013~0209182013~03Mail Transaction~041` 539` 530~0110082013~0210082013~0312200-~05512~0611688-~0772162~08Payments b +y Check~23K~25P` 510~0110082013~0210082013~03Mail Transaction~041` 539` 599~0110102013~02Ending Balance~0372162~10Total Aggregate Amount Paid +From Open~12Total Interest Paid From Open~136063~141218~15 65838` 570~0112183~0311042013~0411042013~0512162~0712162~0844~1112183` 540~012~0224384` 550~01Interest Paid~026063~031218~06609~071749~0865838~091218` 690~010004~032219~04600` 701~01PERSONAL LOAN~0272162`
You should see by running that code that I get dumped every field that I need stripped of the ~ and 2 digits. I actually do not need the 12 digits after 200~. I have parsed that out previously in my script for later use, so I shifted.#! /usr/bin/perl use strict; use warnings; use IO::File; use Data::Dumper; my $in_fh = $ARGV[0]; open(my $in_fh = IO::File->new, "<", $infile) or die "Can't open $infile: $!.\n"; close $in_fh; my $chunk =~ s/[\f\r\n]//g; my @statement = split '`', $chunk; chomp @statement; foreach my $line (@statement) { my @fields = split '~\d\d', $line; next unless length $line; next unless scalar(@fields); my $fieldno = shift @fields; print Dumper(@fields); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Statement Parsing and Rendering
by GotToBTru (Prior) on Oct 24, 2013 at 22:12 UTC | |
by PerlSufi (Friar) on Oct 24, 2013 at 23:42 UTC | |
|
Re: Statement Parsing and Rendering
by boftx (Deacon) on Oct 25, 2013 at 00:41 UTC | |
|
Re: Statement Parsing and Rendering
by hdb (Monsignor) on Oct 25, 2013 at 09:54 UTC | |
by PerlSufi (Friar) on Oct 25, 2013 at 13:56 UTC | |
by PerlSufi (Friar) on Oct 25, 2013 at 14:34 UTC | |
|
Re: Statement Parsing and Rendering
by PerlSufi (Friar) on Oct 25, 2013 at 19:47 UTC |