Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Help splitting Excel file

Expand Messages
  • Charles K. Clarkson
    ... my $index = -1; my @cart; while ( ) { chomp; if ( /^ / ) { $index++; my $str = join | , split / , | ,|, |,/; for ( $str ) { s/ //g; # delete extra
    Message 1 of 2 , Nov 29, 2002
    • 0 Attachment
      techybill [billbaiden@...] asked:
      :
      : I have a Excel file that I need to split the file looks like this,
      :
      : "2191A","3P3XA4631RT523659",1994,"PLYMOUTH","ACCLAIM","4
      : DOOR","WHITE",95583,5988.00,"AUTO"
      : ,,,,,,,,,"PS"
      : ,,,,,,,,,"PB"
      : ,,,,,,,,,"TILT"
      : ,,,,,,,,,"CC"
      : ,,,,,,,,,"AC"
      : ,,,,,,,,,"CASS"
      : ,,,,,,,,,"6CYL"


      my $index = -1;
      my @cart;
      while ( <DATA> ) {
      chomp;
      if ( /^"/ ) {
      $index++;

      my $str = join '|', split /","|",|,"|,/;
      for ( $str ) {
      s/"//g; # delete extra double quotes
      s/\s//g; # remove excess white space
      }
      $cart[ $index ] = $str;

      } else {
      tr/,"//d;
      $cart[ $index ] .= "; $_";
      }
      }

      This assumes there are no commas in the quoted
      strings. If there are you may wish to use one of
      the CSV (comma separated values) modules on CPAN.



      HTH,

      Charles K. Clarkson
      --
      Head Bottle Washer,
      Clarkson Energy Homes, Inc.
      Mobile Home Specialists
      254 968-8328
    Your message has been successfully submitted and would be delivered to recipients shortly.