Excel formatting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Excel formatting
# 1  
Old 11-20-2009
Excel formatting

Dear folks,

Need a help in Excel processing, I have a sheet which need to be changed to a format as below:

Code:
 
Name Eng Hin SS 
A        100  90   83 
B         76   99   90
C         55   34   78

Want the above sheet to below format

Code:
 
Name Sub Marks
A        Eng  100
         Hin    90
         SS    83
B        Eng   76
         Hin    99
         SS    90
So.. On

Can anyone help me with this.... Excel formula or UNIX.... Looking forward for same.. Same thing attached in Excel sheet
# 2  
Old 11-20-2009
Is this what you are looking for?

Code:
awk 'BEGIN { print "Name Sub Marks"; } NR>1{printf "%s English %s\n%s Hin %s\n%s SS %s\n", $1, $2,$1,$3,$1,$4 }' file

file should be a text file.
# 3  
Old 11-20-2009
Could you clarify if the sheet is saved as csv or xls.

1. if csv then you have solutions in earlier post by dennis.jacob

2. if xls

a. then you could use perl,python etc to extract data for perl use libraries like use Spreadsheet::Read; ... to read the content.

b. try antiexcel antiexcel | Get antiexcel at SourceForge.net or similar to extract data ..

Let us know which one worked for you.
# 4  
Old 11-20-2009
In excel, you have the "TRANSPOSE" function to shift the vertical/horizontal orientation.
# 5  
Old 11-20-2009
@dennis.jacob and @chakrapani thanks a lot for your response

Code:
awk 'BEGIN { print "Name Sub Marks"; } NR>1{printf "%s English %s\n%s Hin %s\n%s SS %s\n", $1, $2,$1,$3,$1,$4 }' file

Tried above code but their is a problem, if their are no blanks then working fine but in case of blanks not able to get a blank for instance:

Code:
Name Eng Hin SS 
A        100         83 
B                99   90
 
 
For A's Hin marks is blank and B's Eng is blank

Output should take blanks, but the above script gives this output

Code:
Name Sub Marks
A        Eng  100
          Hin    83
          SS    
B        Eng  99
          Hin    90
        SS    



---------- Post updated at 01:06 PM ---------- Previous update was at 01:02 PM ----------

Quote:
Originally Posted by shaliniyadav
@dennis.jacob and @chakrapani thanks a lot for your response

Code:
awk 'BEGIN { print "Name Sub Marks"; } NR>1{printf "%s English %s\n%s Hin %s\n%s SS %s\n", $1, $2,$1,$3,$1,$4 }' file

Tried above code but their is a problem, if their are no blanks then working fine but in case of blanks not able to get a blank for instance:

Code:
Name Eng Hin SS 
A        100         83 
B                99   90
 
 
For A's Hin marks is blank and B's Eng is blank

Output should take blanks, but the above script gives this output

Code:
Name Sub Marks
A        Eng  100
        Hin    83
        SS    
B        Eng  99
        Hin    90
      SS    

Or something which can exclude the blank records could be better:

Like above case will be:
Code:
Name Sub Marks
A        Eng  100
         SS    83
B        Hin    99
         SS    90
      Excluding the blank records 

# 6  
Old 11-22-2009
Code:
my @subs;
while(<DATA>){
	my @tmp = split;
	if($. eq 1){
	  print "Name Sub Marks\n";
	  @subs=@tmp[1..$#tmp];
	}
	else{
	  print $tmp[0]," ",$subs[0]," ",$tmp[1],"\n";
		for(my $i=2;$i<=$#tmp;$i++){
			print "  ",$subs[$i-1]," ",$tmp[$i],"\n";
		}
	}
}
__DATA__
Name Eng Hin SS 
A    100  90   83 
B    76   99   90
C    55   34   78

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formatting data to put it in the excel file

Hello, I have a file with the below contents : Policy Name: Backup_bkp Policy Type: Catalog_bkp Active: yes Effective date: 08/07/2013 02:02:12 Mult. Data Streams: no Client Encrypt: no Checkpoint: no Policy Priority: ... (11 Replies)
Discussion started by: rahul2662
11 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

Data formatting in CSV file to EXCEL

Hello friends I want to convert an csv file on unix (which is generated by a ETL application) to a formatted excel sheet like .I have roughly like 28 columns 1)All numbers need to be stored as numbers with leading zeros-like format as text for this column to preserve leading zeroes e.g... (6 Replies)
Discussion started by: etldev
6 Replies

4. Shell Programming and Scripting

Perl script to Merge contents of 2 different excel files in a single excel file

All, I have an excel sheet Excel1.xls that has some entries. I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls These may be in different workbooks. They are totally independent made by 2 different users. I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies

5. Shell Programming and Scripting

Writing excel file using perl : Excel file formatting changed

I am trying to create a program where user can input data in certain excel cells using user interface on internet....the programming is on perl and server is unix But when i parse data into excel the formatting of sheets is turned to default and all macro coding removed. What to do...Please... (7 Replies)
Discussion started by: mud_born
7 Replies

6. Shell Programming and Scripting

Formatting Shell script output to Excel

I am facing a problem formatting the output of my shell script in excel. We are directing the output of the script to an excel sheet and need long integer type data printed in Excel as it is (i.e. not in the default scientific notation). Also, leading zeroes(if any) in the output are getting... (4 Replies)
Discussion started by: bornali.p
4 Replies

7. Shell Programming and Scripting

Problem in formatting output of SQL query in excel sheet in shell script

Hi Guys.. Need your help to format the output of my shell script. I am using spool command to take out put in csv file. below is my code. (for example) col USERNAME for a15 col EMAIL for a30 col FULL_NAME for a20 col LAST_LOGIN for a40 col DATE_CREATED for a40 SPOOL 120.csv... (3 Replies)
Discussion started by: Agupte
3 Replies

8. Shell Programming and Scripting

PERL: Modify Excel cell formatting

Hi, I would like to modify an existing excel cell format to a custom format. Is there a way to do it with out writing into a new excel file. In-place editing? Thanks (0 Replies)
Discussion started by: sandeep78
0 Replies

9. Shell Programming and Scripting

PERL: Split Excel Workbook to Indiv Excel files

Hi, I am trying to find a way to read an excel work book with multiple worksheets. And write each worksheet into a new excel file using perl. My environment is Unix. For example: I have an excel workbook TEST.xls and it has Sheet1, Sheet2, Sheet3 worksheets. I would like to create... (2 Replies)
Discussion started by: sandeep78
2 Replies

10. Filesystems, Disks and Memory

Formatting excel file

Hi, I have a problem in formatting the excel file from my script. Assume that there is a text file generated using a 'C shell Unix script' with a format similar to the one seen below. Each column has a fixed length and every row is going to have a value against a column depending on the... (1 Reply)
Discussion started by: subra
1 Replies
Login or Register to Ask a Question