troubleshooting Question

removing blank lines and making the data as comma separated in text file

Avatar of syarra
syarra asked on
Perl
19 Comments1 Solution299 ViewsLast Modified:
Hi,
  I have a text file,that i got from running the sql query.There are 5 columns.I need to remove column

names and the "-------" under the column names.I did removed column names and "-------".That leaves 2

blank lines at starting of the file.I have 400 rows of data.After the data there is some text.I removed

that text also.That leaves 1 blank line at the bottom of the file.Can some body please tell me how to

remove those blank lines?


And i need to make that data as comma separated.


Example file: empData.txt

column1   column2  column3    coloum4             column5
---------   ---------    ---------    --------               --------
 abcd         N           Y            Bank of America    580 LA
 xyz           Y            N           Bank of Africa        765 DC


I started writing getEmpData.pl as follows.

#!usr/bin/perl

`isql -Uusername -Ppwd -Sserver -isqlfile -oempData.txt`;    #this line is to run sql query.

`perl -pi -e s/\.*empno.*//g empData.txt`;      # to remove column names
`perl -pi -e s/\-*//g empData.txt`;                  # to remove ---------
`perl -pi -e s/\.*return.*//g empData.txt`;      # to remove some text


I am new to perl.Just learning from two days.Can somebody help me out with this?

Thanks,
syarra.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 19 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 19 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros