Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: raw data formatting

by Kenosis (Priest)
on Nov 16, 2012 at 03:24 UTC ( [id://1004114]=note: print w/replies, xml ) Need Help??


in reply to Re^4: raw data formatting
in thread raw data formatting

What do the indexes look like, i.e., how do they appear in your file?

Noticed that line "F" doesn't wrap if it's the very last DATA line, since it doesn't have a newline at it's end. Thus, make the following two changes and I'll do the same in the original posting:

while ( chomp( my @lines = $it->() ) ) {

and

print for map { s/\s+/$letter++ . ' '/e; "$_\n" } @lines;

Remove the print "\n"; line.

Replies are listed 'Best First'.
Re^6: raw data formatting
by teamassociated (Sexton) on Nov 16, 2012 at 13:25 UTC
    Here is the entire file: I need to skip the 1st 88 indexes and do not need any line that do not start w/ a space then a digit...this seemed to of work:
    next if ($lines[0] !~ /\A\s+\d+/);
    thank you again!

      Use <code> tags for data please. This data (unike your initial post) seemingly contains real names (as well as things titled PHONE, BAD_DEBT, State/Area/zip codes and what could be social security information), are you sure you should be posting this anywhere?

        yeah ur right...ok I scrubbed the file and made it not as long. There is no S/S info in this file.

      A grep on the data to check for four spaces followed by a digit at the beginning of each line works:

      use strict; use warnings; use List::MoreUtils qw/natatime/; my $it = natatime 5, grep /\A\s{4}\d/, <DATA>; while ( chomp( my @lines = $it->() ) ) { my $letter = 'A'; my $acctNum = do { $lines[0] =~ /\s+(\d+)\s+(\d+)/; $1 . $2 }; push @lines, " acctnum=$acctNum"; print for map { s/\s+/$letter++ . ' '/e; "$_\n" } @lines; } __DATA__ Place your data here...
        Hey, thanks for posting the real data again, good luck notifying the owners of this security breach
        The solution was two fold: Kenosis provided this solution, thnk U! 1. I needed to take out the /r in b/c my Perl is 5.8.8
        print for map { s/\s+/$letter++ . ' '/er} @lines; print for map { s/\s+/$letter++ . ' '/e; "$_\n" } @lines;

        2. I replaced
        my $it = natatime 5, <DATA>; with my $it = natatime 5, grep /\A\s{4}\d/, <DATA>;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1004114]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-26 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found