Creating a report from csv file.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Creating a report from csv file.
# 1  
Old 09-02-2010
Bug Creating a report from csv file.

Hi Gurus,

I need your help in transforming the CSV file into some what a report format.

My source file looks like below
Code:
Date,ProdID,TimeID,LevelID
2010-08-31,200,M,1
2010-08-31,201,Q,2
2010-08-31,202,Y,1
2010-08-31,203,M,5

Output required is
Code:
_____________________________________________________________
|Date     |2010-08-31 | 2010-08-31 | 2010-08-31 | 2010-08-31 |
--------------------------------------------------------------
|ProdID   |200        |201         |202         |203         |
--------------------------------------------------------------
|Time ID  |M          |Q           |Y           |M           |
--------------------------------------------------------------
|LevelID_ |1          |2           |1           |5           |
--------------------------------------------------------------

Could anyone in the forum help me.

Thanks
Naveen.

Moderator's Comments:
Mod Comment Please take the time to format your posts more carefully. Thank you.

Last edited by Scott; 09-02-2010 at 01:31 PM.. Reason: Code tags, formatting
# 2  
Old 09-02-2010
Search for rows to columns with the search function right above this page.

Regards
# 3  
Old 09-02-2010
Quote:
Originally Posted by Franklin52
Search for rows to columns with the search function right above this page.

Regards
I have searched but didn't able to find how to create the report layout.
# 4  
Old 09-02-2010
nawk -f nav.awk sourceFile.csv

nav.awk:
Code:
BEGIN {
  FS=","
  OFS="|"
}
{
  for(i=1; i<=NF;i++)
    arr[FNR,i]=$i
  nf=NF
  fnr=FNR
}
END {
  for(i=1; i<=nf;i++)
    for(j=1; j<=fnr;j++)
      printf("%s%c", arr[i,j], (j==fnr)?ORS:OFS)
}

# 5  
Old 09-02-2010
Hi.

I also remember this excellent thread (post by drl)

https://www.unix.com/shell-programmin...e-ascii.html#3
# 6  
Old 09-02-2010
---------- Post updated at 10:01 PM ---------- Previous update was at 10:00 PM ----------

[/COLOR]
Quote:
Originally Posted by scottn
Hi.

I also remember this excellent thread (post by drl)

https://www.unix.com/shell-programmin...e-ascii.html#3
Unfortunately, the link isn't working Smilie

Last edited by naveen.kuppili; 09-02-2010 at 01:37 PM..
# 7  
Old 09-02-2010
Really? Works for me! Still. Try this.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Creating a csv file with header in UNIX

I have a flat file that contains dynamic list of variables like a=1 b=2 c=3 . .. z=26 I need to convert the above into a csv file having the format below: a,b,c,..,z 1,2,3,..,26 Please note, I do not want a comma separating the last variable. I tried to refer the post... (4 Replies)
Discussion started by: vkumbhakarna
4 Replies

2. Shell Programming and Scripting

reading a csv file and creating a flat file

hi i have written a script for reading a csv file and creating a flat file, suggest if this script can be optimized #---------------- FILENAME="$1" SCRIPT=$(basename $0) #-----------------------------------------// function usage { echo "\nUSAGE: $THIS_SCRIPT file_to_process\n"... (3 Replies)
Discussion started by: mprakasheee
3 Replies

3. UNIX for Dummies Questions & Answers

Problem in creating CSV file

Hi guys, I am not experienced with Unix, so please dont mind if the question seem to be irrelevant. I have written a simple script, that connects DB & fetches few records from a table. I wanted to get those details as file in .CSV format via mail. -I stored the query o/p in a file. -I... (6 Replies)
Discussion started by: sumitburnwal88
6 Replies

4. Shell Programming and Scripting

creating a csv file from this 1 liner?

I'm trying to create a csv file by running awk and sed on a number of xml files in a directory; I'm using this below: hostname; grep "BuildDate" /dir/ABCD/configuration/*/*.xml | awk -F"/" '{ print $5 }' > /tmp/tempfile.txt; grep "BuildDate" /dir/ABCD/configuration/*/*.xml | awk -F\" '{ print $2... (2 Replies)
Discussion started by: rich@ardz
2 Replies

5. Shell Programming and Scripting

CSV file report

Hi, I need to create a csv file using unix script on hourly manner. The report should be in format "Report_22_Sep_09_16IST.csv". Could you please suggest me. Thanks (1 Reply)
Discussion started by: Sekar1
1 Replies

6. UNIX for Dummies Questions & Answers

creating a CSV file for past 7 days

I have a requirement which will select the files with a specific naming convention which got created in past 7 days in a specific directory.Lets say the directory is /data/XYZ and the file names follow the below nomenclature like Daily_File*.txt I just need to create one CSV file which will... (12 Replies)
Discussion started by: dr46014
12 Replies

7. UNIX for Advanced & Expert Users

Creating multiple worksheets in CSV file

Hello, I've been tasked with sending 3 types of data (file size, row count, and file name) to a csv file every month for various vendors. I have been asked to put this in one csv or xls file with each vendor being a different tab (or worksheet). Until now, we have been finding and emailing... (4 Replies)
Discussion started by: tekster757
4 Replies

8. Shell Programming and Scripting

creating a csv file in awk

Hi All I am trying to create a csv file in the korn shell and the script segment is as follows: if then # NEED TO ADD INFO TO THE EMAIL FILE ABOUT THE DRIVE THAT'S FILLING UP echo "$drive $percent% $space "|\ awk '{printf("%d/t"|"%d/t"|"%d/t\n",... (6 Replies)
Discussion started by: Segwar
6 Replies

9. Shell Programming and Scripting

Creating a csv file based on Existing file

Hi I am Newbie to Unix.Appreciate Help from forum user would loada b.Csv File(Below example) in /data/m/ directory.Program need to read the b.csc to extract certain column and create a new file /data/d/ directory as csv file with new name. User File Format 1232,samshouston,12345... (3 Replies)
Discussion started by: skywayterrace
3 Replies

10. Shell Programming and Scripting

help!!!!!! in creating csv report

Dear All, I need the help of all the genius minds to find solution to my problem. This problem has left me in a situation like I am in middle of sea with a rubber boat , so please help me out to get out of this. Problem:-- I m using the informix database with installed on linux machine and... (6 Replies)
Discussion started by: xander
6 Replies
Login or Register to Ask a Question