Unix/Linux Go Back    



Make Multile line is one line using window Perl

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member adisky123 Regarding:
Make Multile line is one line using window Perl.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old Unix and Linux 12-28-2012   -   Original Discussion by adisky123
adisky123 adisky123 is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 23 December 2013, 5:57 AM EST
Posts: 58
Thanks: 5
Thanked 0 Times in 0 Posts
Make Multile line is one line using window Perl

Hi All

I have a .csv file which is showing data as


Code:
ESP Client,ESP Engagement,Misc_Projects_120101,DEFAULT,HA,Unknown,No,Unknown,201704,4.1,Unknown,AAA,Collected-Done,"she,joy.",200111,Unknown,Full Time,,Delivery_DONE AMO,Approved,2012-12-03,2012-12-06,2012-12-06,"Occupied Hours 
(0)",0,"Approved Hours 
(112)",8,"Pending Hours 
(0)",0,"Pending and Approved Hours 
(112)",8,

ESP Client,ESP Engagement,Misc Projects_120101,DEFAULT,HR,Unknown,No,Unknown,201704,4.1,Unknown,AAA,Collected - Pending,"she, aj v.",200111,Unknown,Full Time,,Delivery_Pending AMO,Approved,2012-12-04,2012-12-14,2012-12-14,"Occupied Hours 
(0)",0,"Approved Hours 
(112)",8,"Pending Hours 
(0)",0,"Pending and Approved Hours 
(112)",8,

I want to make in one line like using windows Perl

Code:
ESP Client,ESP Engagement,Misc_Projects_120101,DEFAULT,HA,Unknown,No,Unknown,201704,4.1,Unknown,AAA,Collected-Done,"she,joy.",200111,Unknown,Full Time,,Delivery_DONE AMO,Approved,2012-12-03,2012-12-06,2012-12-06,"Occupied Hours (0)",0,"Approved Hours(112)",8,"Pending Hours(0)",0,"Pending and Approved Hours(112)",8,
ESP Client,ESP Engagement,Misc Projects_120101,DEFAULT,HR,Unknown,No,Unknown,201704,4.1,Unknown,AAA,Collected - Pending,"she, aj v.",200111,Unknown,Full Time,,Delivery_Pending AMO,Approved,2012-12-04,2012-12-14,2012-12-14,"Occupied Hours(0)",0,"Approved Hours(112)",8,"Pending Hours(0)",0,"Pending and Approved Hours(112)",8,

What I have tried is

Code:
open('NEW',"<$new_file") || die "Error open file $new_file\n";

  while (my $s2=<NEW>) {
      if($s2 =~ /ESP General Client/){
          
          if ($flag==1){
              print NEW1 $new;
              $flag=0;
          }
          my $new=$s2;
      }
      else{
          $new .= ''.$s2;
          $flag=1;
      }
   }
    close(NEW);


But its not working

---------- Post updated at 09:01 AM ---------- Previous update was at 08:59 AM ----------

Sorry the actual code I am using is
open('NEW',"<$new_file") || die "Error open file $new_file\n"; while (my $s2=<NEW>) { if($s2 =~ /ESP Client/){ if ($flag==1){ print NEW1 $new; $flag=0; } my $new=$s2; } else{ $new .= ''.$s2; $flag=1; } } close(NEW);

---------- Post updated at 09:02 AM ---------- Previous update was at 09:01 AM ----------

Sorry the actual code i am using is

Code:
open('NEW',"<$new_file") || die "Error open file $new_file\n";

  while (my $s2=<NEW>) {
      if($s2 =~ /ESP Client/){
          
          if ($flag==1){
              print NEW1 $new;
              $flag=0;
          }
          my $new=$s2;
      }
      else{
          $new .= ''.$s2;
          $flag=1;
      }
   }
    close(NEW);

---------- Post updated at 12:24 PM ---------- Previous update was at 09:02 AM ----------

Its Make Multile line to one line using window Perl