?
Solved

Loop form binary Field to generate Day information

Posted on 2000-05-07
2
Medium Priority
?
189 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
[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
2 Comments
 
LVL 2

Accepted Solution

by:
mattrope earned 200 total points
ID: 2785976
0
 

Author Comment

by:tomatocans
ID: 2786038
Thanks
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Six Sigma Control Plans

719 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