Create excel file using bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create excel file using bash script
# 1  
Old 10-09-2013
Create excel file using bash script

i have written one script which generates text file which gives output like.
Code:
001.config: CR1.1       COMPILE_PASSED           TEST_PASSED
002.config: CR1.1        COMPILE_FAILED            TEST_FAILED
.
.
.so on

this text file will get filled one by one as its for loop for n number.

i want to create excel file which should contain four columns which takes input from above text file. it should look like
Code:
____________________________________________________
test id         Release        compilestatus        executionstatus
_____________________________________________________ 
001.config:   CR1.1       COMPILE_PASSED         TEST_PASSED
002.config:   CR1.1        COMPILE_FAILED          TEST_FAILED

so we can fill excel one by one as text file is getting filled as per script exceution or at the end we can take all completed text file and just do copy paste from text file to excel.

can nybody please tell me how to do this task using shell script

Last edited by Scott; 10-09-2013 at 05:10 AM.. Reason: Code tags please...
# 2  
Old 10-09-2013
For bash, I believe the best you could do is to create a CSV file.
If you could do it in perl, making an excel file is possible.
# 3  
Old 10-09-2013
Have your first script writing ";" between the values.
Then all you need to do is open it in excel as cvs.

Should have figured in other post as well.
# 4  
Old 10-09-2013
Quote:
Originally Posted by sea
Have your first script writing ";" between the values.
Then all you need to do is open it in excel as cvs.

.
Hi my first script which is generating text file which doenst have ; between the values. i have just inserted spaces to separete the output values.

first time i am trying to genarate .csv file so i dont know how to name columns and appropriate data in those columns.

Thanks to reply if you know this.

---------- Post updated at 02:03 PM ---------- Previous update was at 02:02 PM ----------

Quote:
Originally Posted by MR.bean
For bash, I believe the best you could do is to create a CSV file.
If you could do it in perl, making an excel file is possible.
Hi,
.csv is ok for me.

Can you please tell me how do this task??
# 5  
Old 10-09-2013
Quote:
Originally Posted by RamMore123
Hi my first script which is generating text file which doenst have ; between the values. i have just inserted spaces to separete the output values.
...
Thanks to reply if you know this.
..
Hi,
.csv is ok for me.
Can you please tell me how do this task??
When you generate the 'rawfile', merley instead of putting spaces as seperator, you use ";" straight.
Each ";" defines a new 'field', so you can use "test id" ; "other value" and so on for the title, and val1 ; val2 ; val3 ; val4 for the following values.

If you're willing to share that script, we could help better.
# 6  
Old 10-09-2013
Quote:
Originally Posted by sea
When you generate the 'rawfile', merley instead of putting spaces as seperator, you use ";" straight.
Each ";" defines a new 'field', so you can use "test id" ; "other value" and so on for the title, and val1 ; val2 ; val3 ; val4 for the following values.

If you're willing to share that script, we could help better.
Hi,

i have attached some part of script 'script.txt' raw file generated by script. i have used your code to generate .csv file . csv file contains below output.
FC/B_096.config ; FR2.0 ; COMPILE_PASSED ; TEST_FAILEDFC/B_019.config ; FR2.0 ; COMPILE_PASSED ;TEST_PASSED

so we need to convert this .csv file to excel format and why column names are not coming in .csv file??
thanks
# 7  
Old 10-09-2013
Code:
if [ $errstat -ne 0 ]; then 
( 
    echo "FC/$i  $FRRELEASE  COMPILE_FAILED  TEST_FAILED" 
) >> $SPECIALLOGDIR/$RESULTFILE

Becomes:
Code:
if [ $errstat -ne 0 ]; then 
( 
    echo "FC/$i ; $FRRELEASE ; COMPILE_FAILED ; TEST_FAILED" 
) >> $SPECIALLOGDIR/$RESULTFILE

AND

Code:
if [ $RESULT -eq 0 ]; then 
    echo "FC/$i  $FRRELEASE  COMPILE_PASSED  TEST_PASSED"; 
elif [ $RESULT -eq 1 ]; then 
    echo "FC/$i  $FRRELEASE  COMPILE_PASSED  TEST_FAILED"; 
else [ $RESULT -eq 2 ]; 
      echo "FC/$i  $FRRELEASE  COMPILE_PASSED  TEST_FAILED_UNKNOWN_BREAKPOINT"     
fi

Becomes:
Code:
if [ $RESULT -eq 0 ]; then 
    echo "FC/$i ; $FRRELEASE ; COMPILE_PASSED ; TEST_PASSED"; 
elif [ $RESULT -eq 1 ]; then 
   echo "FC/$i ; $FRRELEASE ; COMPILE_PASSED ; TEST_FAILED"; 
else [ $RESULT -eq 2 ]; 
    echo "FC/$i ; $FRRELEASE ; COMPILE_PASSED ; TEST_FAILED_UNKNOWN_BREAKPOINT"     
fi

hth
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. UNIX for Dummies Questions & Answers

How to Create excel file(.csv) using shell script?

Hi, i have shell script which compiles n number of test cases and execute them one by one. i want to create report in excel through script in which two columns namely "test id" and "release".second column have two subcolumns namely compiles and excutes. so i want first column should display test... (15 Replies)
Discussion started by: RamMore123
15 Replies

4. Homework & Coursework Questions

Create a simple bash backup script of a file

This is the problem: Write a script that will make a backup of a file giving it a ‘.bak’ extension & verify that it works. I have tried a number of different scripts that haven't worked and I haven't seen anything really concise and to the point via google. For brevity's sake this is one of the... (4 Replies)
Discussion started by: demet8
4 Replies

5. Shell Programming and Scripting

create separate files from one excel file with multiple sheets

Hi, I have one requirement, create separate files (".csv") from one excel file(xlsx) with multiple sheets. These ".csv" files are my source files. So anybody please suggest me the process. Thanks in Advance. Regards, Harris (3 Replies)
Discussion started by: harris
3 Replies

6. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

7. Shell Programming and Scripting

Create a .sh file for an equivalent Excel VBA code

Hi guys, I am new to Unix, Need your help here. I have installed cygwin software (Unix) in my computer (Windows vista). Now i want to create a shell script (.sh file)/other script which is equivalent of VBA code (at the bottom) and then put this .sh file into bin directory of c:/cygwin. so... (7 Replies)
Discussion started by: bansalpankaj88
7 Replies

8. Shell Programming and Scripting

Create an .csv/excel file using shellscript

In my file, i have 4 Product names(For ex:Microsoft excel, Oracle,.Net,IBM websphere,..etc.,) I want this 4 Products in 4 individual .csv/excel file after running the script with those products related information. (12 Replies)
Discussion started by: Navya
12 Replies

9. UNIX for Dummies Questions & Answers

create excel file

Hi, How can I create an excel file from a txt file using shell script. Please do a help for me. Thanks, Regards, Milton (6 Replies)
Discussion started by: miltony
6 Replies
Login or Register to Ask a Question