format csv file using shell script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users format csv file using shell script
# 1  
Old 06-26-2007
format csv file using shell script

i have a report.csv file from oracle datavase
In that file data is like this with report heading and date

SALES DAILY REPORT
DATE: 06-26-2007
REPORT NAME: SALES DATA

AA.BB.CCCC.DDDD,BBBBB,06-26-2007,0,BEGIN,END
ZZ.VV.DDDD.XXXXXXX,MMMMMM,06-25-2007,18,BEGIN,END
CC.XX.VVV.QQ,KKKKK,06-24-2007,END,BEGIN
fields are separated with ",".
i want to read this file create new file with new format.

i want
col1 WIDTH should increse 15 positions with spaces right side
col2 WIDTH should increse 10 positions with spaces right side
col3 WIDTH should increse 5 positions with spaces right side
col4 WIDTH should increse 7 positions with spaces right side
col5 WIDTH should increse 7 positions with spaces right side
col6 WIDTH should increse 6 positions with spaces right side
BUT HEADING OF THE REPORT SHOULD NOT BE CHANGED.

I WANT NEW OUTPUT FILE SHOULD BE LIKE THIS
Code:
SALES DAILY REPORT
DATE: 06-26-2007 
REPORT NAME: SALES DATA

AA.BB.CCCC.DDDD          ,BBBBB     ,06-26-2007   ,0   ,BEGIN   ,END
ZZ.VV.DDDD.XXXXXXX        ,MMMMMM     ,06-25-2007,18  ,BEGIN   ,END
CC.XX.VVV.QQ      ,KKKKK    ,06-24-2007       ,15     ,END    ,BEGIN


Thanks for your help
i need answer desparately.
N.
# 2  
Old 06-26-2007
raosurya,
now that we all know your 'needs' and your previous postings on a very similar subject, what are you desperate "deeds" to find a solution given all of the above?
Are you looking for help or are you leaching for a solution to a similar previously posted question?
Show the 'effort' and you might get a 'helping hand'.
# 3  
Old 06-27-2007
No. absolutely NOT. some body gave me answer for this question which is not working. i posted reply in other post. but, NO body replied to me last week.thats why i asked the question again. I am sorry that. still i did n't get the answer yet. pl see code bellow. when i put this code the i am getting empty file.but, i must get the results.file should never be empty.

this is code replied to me:
Code:
awk 'BEGIN{
FS=","
print "<HTML><BODY><TABLE>"
}
{
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
}
END{
print "</TABLE></BODY></HTML>"
}
'Report.csv > Report11.xls

i understand every body's help. I am looking for answer.
i appreciate that.pl help me.
thx,N
# 4  
Old 06-27-2007
You've been helped with more than 1 possible solutions. If you're not seeing the desired result do show the 'effort' explaining what you've done to understand the solutions and to improve on it. A simple 'it does not work' will not help you getting somebody's attention.

Also pls read the Rules of these forums paying attention to #4:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post or send a private message where your goal is to get an answer more quickly.

I'm closing the 'duplicate' thread.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies

2. Shell Programming and Scripting

Format CSV file from a shell script

I have a shell script which creates a CSV files. there are 3 fields, field1, field2 and comp. I will generates the values for field1 and field2 and Want to compare both. If field1>filed2 then comp should be success written in green in CSV file, else it should fail in red color. How can I change the... (5 Replies)
Discussion started by: sauravrout
5 Replies

3. Shell Programming and Scripting

Need perl or shell script to sort vertical lines to horizontal line in csv format

Need perl or shell script to sort vertical lines to horizontal line in csv format My file like below ------------------------- ================================================================================ PATH PINKY1000#I1-1-ZENTA1000-2#I7-1-ASON-SBR-UP-943113845 ... (4 Replies)
Discussion started by: sreedhargouda.h
4 Replies

4. Shell Programming and Scripting

Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- ----- ---------------------------------... (7 Replies)
Discussion started by: sreenath1037
7 Replies

5. Programming

awk script to convert a text file into csv format

hi...... thanks for allowing me to start a discussion i am collecting usb usage details of all users and convert it into csv files so that i can export it into some database.. the input text file is as follows:- USB History Dump by nabiy (c)2008 (1) --- Kingston DataTraveler 130 USB... (2 Replies)
Discussion started by: certteam
2 Replies

6. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

7. UNIX for Advanced & Expert Users

shell script to format .CSV data

Hi all, I have written a shell script to search a specified directory (e.g. /home/user) for a list of specific words (shown as ${TMPDIR}/wordlist below). The script works well enough, but I was wondering if there was a way to display the line number that the word is found on? Thanks! cat... (1 Reply)
Discussion started by: tmcmurtr
1 Replies

8. UNIX for Dummies Questions & Answers

Option in sql script to include column headers when spooling file to .csv format

Can anyone help me how to include COLUMN HEADER when spooling file to .CSV format through SQL statement. Thanks, Akbar (4 Replies)
Discussion started by: s1a2m3
4 Replies

9. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

10. Shell Programming and Scripting

Shell script to format a .CSV data

Hi There I needed to write a Unix shell script which will pick up the data from a .CSV file and reformat it as per the requirement and write it to another .CSV file. Currently I am in the proess of Data Import to "Remedy System" (A one kind of incident mangement Application) and this... (8 Replies)
Discussion started by: Uday1982
8 Replies
Login or Register to Ask a Question