Solved

Loop form binary Field to generate Day information

Posted on 2000-05-07
2
170 Views
Last Modified: 2010-03-05
The last problem is that the binary info for days is not
transferring to the day array and printing out.


Example of input:
01|1101111110111111011111101111110|1999|0605|0605|0700|0700|KIR |EIDW|F50 |00021|     |0055|   |                           | | |EI|511860|03426}|516360|02250}|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN
01|1111111111111111111111111111111|1999|1240|1240|1345|1345|EIDW|KIR |F50 |00022|     |0065|   |                           | | |EI|516360|02250}|511860|03426}|DUB||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN
01|1111111111111111111111111111111|1999|1410|1410|1505|1505|KIR |EIDW|F50 |00023|     |0055|   |                           | | |EI|511860|03426}|516360|02250}|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN
05|1000000100000010000000000000000|1999|1730|1630|1905|1805|EGBB|EICK|BA46|00767|  288|  95|   |AER LINGUS                 | |A|EI|512820|00630}|510600|03054}|BHX||4930|4410|BIRMINGHAM: ENGLAND (UK)   |CORK: REPUBLIC OF IRELAND  | 75|146|J|UNITED KINGDOM             |REPUBLIC OF IRELAND        |EIN
05|0000000000000000000001000000100|1999|1730|1630|1845|1745|EGBB|EICK|BA46|00767|  288|  75|   |AER LINGUS                 | |A|EI|512820|00630}|510600|03054}|BHX||4930|4410|BIRMINGHAM: ENGLAND (UK)   |CORK: REPUBLIC OF IRELAND  | 75|146|J|UNITED KINGDOM             |REPUBLIC OF IRELAND        |EIN
05|0100000010000001000000000000000|1999|1845|1745|2010|1910|EICK|EGBB|F50 |00768|  288|  85|   |AER LINGUS                 | |C|EI|510600|03054}|512820|00630}|ORK||4410|4930|CORK: REPUBLIC OF IRELAND  |BIRMINGHAM: ENGLAND (UK)   | 50|F50|T|REPUBLIC OF IRELAND        |UNITED KINGDOM             |EIN

Code


#usr/local/bin/perl -w

open INPUT,"</home/tmclaugh/oag/bin/ein99_prep" or die "can't open ein99_prep $!";
open OUTPUT,">/home/tmclaugh/oag/bin/flight.dbload" or die "can't open flight.dbload $!";

$UID='000000';
while($line=<INPUT> ){
            
                @fields=(split(/\|/,$line));
                $month=$fields[0];
                $days=$fields[1];
                $year=$fields[2];
                $departure_local_time=$fields[3];
                $departure_gmt_time=$fields[4];
                $arrival_local_time=$fields[5];
                    $departure_gmt_time=$fields[6];
                    $arrival_airport_id=$fields[7];
                    $departure_airport_id=$fields[8];
                    $aircraft_type=$fields[9];
                    $flight_number=$fields[10];
                    $distance=$fields[11];
                    $elapsed_time=$fields[12];
                    $ata_carrier_id=$fields[13];
                    $air_carrier_full_name=$fields[14];
                    $operator_type=$fields[15];
                    $carrier_type=$fields[16];
                    $carrier_code=$fields[17];
                    $departure_latitude=$fields[18];
                    $departure_longitude=$fields[19];
                    $arrival_latitude=$fields[20];
                    $arrival_longitude=$fields[21];
                    $ata_departure_airport_id=$fields[22];
                    $ata_arrival_airport_id=$fields[23];
                    $departure_country_code=$fields[24];
                    $arrival_country_code=$fields[25];
                    $departure_city=$fields[26];
                    $arrival_city=$fields[27];
                    $seats=$fields[28];
                    $ata_aircraft_type=$fields[29];
                    $equipment_type=$fields[30];
                $departure_country=$fields[31];
                    $arrival_country=$fields[32];
                    $air_carrier_id=$fields[33];
                    if ($departure_longitude=~ /[0-9]{5}[KROM\{]/) {
                            $departure_longitude = "+" . substr($departure_longitude,0,5);
                    }
                    elsif ($departure_longitude =~ /[0-9]{5}[ABCDEFGHIJLNPQ\}]/) {
                            $departure_longitude = "-" . substr($departure_longitude,0,5);
                    }
                    else {
                    }
                    if ($arrival_longitude =~ /[0-9]{5}[KROM\{]/) {
                            $arrival_longitude = "+" . substr($arrival_longitude,0,5);
                    }
                    elsif ($arrival_longitude=~ /[0-9]{5}[ABCDEFGHIJLNPQ\}]/) {
                            $arrival_longitude = "-" . substr($arrival_longitude,0,5);
                    }
                    else {

                    }

                  @day=(0,split//,$days);
                  for(grep $day[$_],1..31){
                  $days=substr"0$_",-2;
                  ++$UID;

                  
                         print OUTPUT "$month$UID|${month}${day}${year}_$departure_local_time|${month}${day}${year}_$departure_gmt_time|${month}${day}${year}_$arrival_local_time|${month}${day}${year}_$arrival_gmt_time|$departure_airport_id|$arrival_airport_id|$aircraft_type|$flight_number|$distance|$elapsed_time|$ata_carrier_id|$air_carrier_full_name|$operator_type|$carrier_type|$carrier_code|$departure_latitude|$departure_longitude|$arrival_latitude|$arrival_longitude|$ata_departure_airport_id|$ata_arrival_airport_id|$departure_country_code|$arrival_country_code|$departure_city|$arrival_city|$seats|$ata_aircraft_type|$equipment_type|$departure_country|$arrival_country|$air_carrier_id\n";

      }
}





Following is the output I am receiving:

01000001|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

01000002|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

01000003|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

01000004|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

01000005|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

01000006|011999_0605|011999_0605|011999_0700|011999_0700|EIDW|KIR |F50 |00021|     |0055|   |                           | | |EI|511860|-03426|516360|-02250|KIR||4410|4410|                           |    AER LINGUS             |   |F50|T|                           |                           |EIN

The last problem is that the binary info for days is not
transferring to the day array and printing out.

PLEASE HELP
Any suggestions appreciated
0
Comment
Question by:tomatocans
2 Comments
 
LVL 2

Accepted Solution

by:
mattrope earned 50 total points
ID: 2785976
0
 

Author Comment

by:tomatocans
ID: 2786038
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Perl script not writing to .csv file 6 106
create a gui in perl 3 72
Perl Untar File 1 27
What does msixpodualn stand for and how do I read this "qr/STRING/msixpodualn"? 4 38
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now