Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

How do I seperate my data in this txt file.

by perltypeofguy (Initiate)
on Mar 03, 2013 at 22:48 UTC ( #1021536=perlquestion: print w/ replies, xml ) Need Help??
perltypeofguy has asked for the wisdom of the Perl Monks concerning the following question:

I have a text file which I managed to split the text and print out to an outfile but when it comes to the rest of data I do not know how to proceed.I am new to perl so sorry if I come off as I do not know what I am doing. I really trying to learn but this is very difficult for me.
my $infile = "COSC146_project01_dataset_2.txt"; #project input file. my $outfile = "fileoutput.txt"; # assigned an output file. open FILE,$infile or die "failed to open!"; #open project text. open OUT, ">fileoutput.txt" or die "failed to output!"; my $line = undef; #read line by line. Assigned global value to the sca +lar line. my $text = <FILE>; # Split on spaces. my @items = split ' ', $text; use Data::Dumper; #print Dumper(@items); print "$items[0]\t"; print "$items[2]\t"; print "$items[1]\t"; print "$items[3]\t"; print "$items[18]\t"; print "$items[23]\t"; print "$items[34]\t"; print "$items[36]\t"; print OUT "$items[0]\t"; print OUT"$items[2]\t"; print OUT"$items[1]\t"; print OUT "$items[3]\t"; print OUT"$items[18]\t"; print OUT "$items[23]\t"; print OUT"$items[34]\t"; print OUT "$items[36]\t";
^^^ is what I have. i have to generate a report for management that looks similar to this, but consolidates each set of four rows and eliminates many of the columns. Your report should be an output file created by your Perl code. The columns to keep in your report are the following:
'Date of Test', 'G400-TYP', 'G400-SN', 'G400-Ver.', 'G400-USER', 'Mode', 'Result', 'DS400-SN.', and 'DS400-Name' Again, re +alize that, for each set of four rows, you may not simply check 'Result' for 'ERR' in the first of each + four-row set. G400-TYP G400-SN. G400-USER G400-Ver. Sensor-Typ Sensor-SNSensor range + A1 A2 A3 STEL TWA LEL-Value STEL-Time Date of Test Mode Test Gas Gas Bottle Res +ult Horn LED tA1 tA2 t50 t90 ZP-before ZP CAL-before CAL DS400-SN. DS400- Name DS400-Ver. DS400-ID G450 09010119 3.44 MK429-00 00000 0.0 - 100.0 ppm H2S 10.0 ppm 30.0 pp +m 15.0 ppm 10.0 ppm 2012-06-20 13:19 CAL 20.0 ppm OK OK OK -0.1 ppm 0.1 ppm 18.8 ppm 20.3 ppm 12063580 -default- 2.21 1 G450 09010119 3.44 MK437-00 00000 0 - 500 ppm CO 35 ppm 50 ppm 50 ppm 35 ppm 2012-06-20 13:19 CAL 200 ppm OK OK OK -1 ppm 0 ppm 203 ppm 200 ppm 12063580 -default- 2.21 1 G450 09010119 3.44 MK427-00 00000 0.0 - 25.0 Vol% O2 19.5 Vol% 17.0 Vo +l% 23.5 Vol% 2012-06-20 13:19 CAL N/A OK OK 20.9 Vol% 20.9 Vol% 12063580 -default- 2.21 1 G450 09010119 3.44 MK221-01 00000 0.0 - 100.0 %LEL CH4 10.0 %LEL 20.0 +%LEL 60.0 %LEL 5.0 Vol% 2012-06-20 13:19 CAL 50.0 %UEG OK OK OK -0.5 %LEL 0.0 %UEG 47.5 %LEL 50.5 %LEL 12063580 -default- 2.21 1 G450 09010119 3.44 MK429-00 00000 0.0 - 100.0 ppm H2S 10.0 ppm 30.0 pp +m 15.0 ppm 10.0 ppm 2012-06-20 13:41 CAL 20.0 ppm OK OK OK -0.3 ppm 0.1 ppm 20.5 ppm 20.3 ppm 12063580 -default- 2.21 1

Comment on How do I seperate my data in this txt file.
Select or Download Code
Re: How do I seperate my data in this txt file.
by ChuckularOne (Parson) on Mar 03, 2013 at 23:04 UTC
    Please clean up the formatting. This is very difficult to read.
Re: How do I seperate my data in this txt file.
by Kenosis (Priest) on Mar 03, 2013 at 23:06 UTC

    Welcome to PerlMonks, perltypeofguy!

    To help with assisting you, please reformat your posting using <code> tags.

Re: How do I seperate my data in this txt file.
by AnomalousMonk (Monsignor) on Mar 04, 2013 at 14:20 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-07-28 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (210 votes), past polls