format output in csv file | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

format output in csv file

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 11-06-2009
Prashant Jain Prashant Jain is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 30 June 2010, 6:01 AM EDT
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Question format output in csv file

I am sending the output of a file to .csv file.
The output should look like this:

Total Customers Processed:,8
Total Customers Skipped:,0
Total Customers Added:,8
Total Customers Changed:,0


Total Policies Deleted:,0
Total Policies Failed:,0

total:,8

Now i want this output in only one cell, i.e line break in the same cell of csv file.like, we use Alt Enter on the cell in excel.

Wht my approach is , first of all i will replace the , with something else, thn i will remove the new line character with some spaces so that data comes in different lines bt in same cell, but its not working..

Please Help.........
Sponsored Links
    #2  
Old 11-06-2009
Franklin52's Avatar
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 17 December 2014, 7:05 AM EST
Location: The Netherlands
Posts: 7,720
Thanks: 126
Thanked 538 Times in 508 Posts
Try this, suppose you want to replace the commas with spaces:


Code:
 awk 'BEGIN{printf("\"")}{gsub(","," ")}END{printf("\"")}1'  file.csv > newfile.csv

Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
format file output zerbitated Shell Programming and Scripting 1 07-21-2009 04:00 PM
format the output from a file becksram123 Shell Programming and Scripting 5 07-05-2009 10:55 PM
Output format - comparison with I/p file velappangs Shell Programming and Scripting 1 04-03-2008 07:31 AM
File Format issue: Output of sqlplus deepakgang UNIX for Dummies Questions & Answers 2 10-25-2007 04:56 AM
Format the output of file getdpg Shell Programming and Scripting 9 01-24-2006 12:50 PM



All times are GMT -4. The time now is 09:30 PM.