a shell script to generate an excel sheet from a text file..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting a shell script to generate an excel sheet from a text file..
# 1  
Old 06-14-2012
a shell script to generate an excel sheet from a text file..

hi,
i have a text file that looks like this!
i want to generate an excel sheet out of it, removing all the junk data except the addresses
that look like

Code:
 . [32]Arrow Electrical Services
       Rotating Machinery, Electrical Contracting & Mining Specialists
       Onsite maintenance, breakdown service. Rotating machinery,
       electrical contracting, variable speed drives, mining services.
       109 Auburn St, Wollongong NSW 2500
       ph: (02) 4229 8094
            [33]www.arrow-electrical.com.au

and
Code:
. [109]JOEST Australia Pty Ltd
       70-72 Sheffield Rd, Welshpool WA 6106
       ph: (08) 9358 3740

i am new to linux and i managed to make that file using shell script.. and struggling with the furthur process,
can somebody help me out..

Last edited by Scrutinizer; 06-14-2012 at 03:45 AM.. Reason: quote tags changed to code tags
# 2  
Old 06-14-2012
Something like this?
Code:
awk '$2 ~ /\. \[/{$1=x; print}' RS=\* FS='\n' OFS='\n' infile

# 3  
Old 06-14-2012
Quote:
Originally Posted by Scrutinizer
Something like this?
Code:
awk '$2 ~ /\. \[/{$1=x; print}' RS=\* FS='\n' OFS='\n' infile


thats good buddy..
but how do i generate an excel sheet?
that was the issue i was facing!Smilie
# 4  
Old 06-14-2012
By changing OFS:
Code:
awk '$2 ~ /\. \[/{$1=x; print}' RS=\*  FS='\n' OFS='|' infile

# 5  
Old 06-14-2012
Quote:
Originally Posted by Scrutinizer
By changing OFS:
Code:
awk '$2 ~ /\. \[/{$1=x; print}' RS=\*  FS='\n' OFS='|' infile


cool thanks a lot buddy!
but can i ask for another favour?
the problem is the address length is varying and the order in the csv isnt proper..
like one record shows two cells of address while other 1 cell.. can we do anythingto that?

btw thanks againSmilie
# 6  
Old 06-14-2012
Do you mean like this?
Code:
awk '$2 ~ /\. \[/{print $2,$(NF-2),$(NF-1),$NF}' RS=\* FS='\n' OFS='|' infile

# 7  
Old 06-14-2012
Quote:
Originally Posted by Scrutinizer
Do you mean like this?
Code:
awk '$2 ~ /\. \[/{print $2,$(NF-2),$(NF-1),$NF}' RS=\* FS='\n' OFS='|' infile

nope! that command is deleting a lot of data! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 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

Need to convert text file into Excel sheet

:cool:Hi, Iam new to this Scripts and forum too. Plz excuse if may i ask silly questions now and further.. Prob: i need to convert txt files data into excel sheet. Suppose if i have hour-wise data in txt file1 and file2 like file1 file2 00: 140 00: 235 01: 160 01:415... (1 Reply)
Discussion started by: mrudula
1 Replies

3. Shell Programming and Scripting

Shell Script for copying text file to Excel Sheet

Hi, I want to write a program to copy a log file to Excel sheet. Excel sheet has four columns MethodName , Code , Description, Details and Time. I want to pick these info from text file and put it in excel sheet. here is how the text file looks - 04.17.2014 08:06:12,697... (1 Reply)
Discussion started by: hershey
1 Replies

4. Shell Programming and Scripting

Adding tab to excel sheet with shell script

(1 Reply)
Discussion started by: sagar_1986
1 Replies

5. Shell Programming and Scripting

Export data from database in Excel sheet with the help of Shell script and automated the report

Export data from database in Excel sheet with the help of Shell script and automated the report every day in the mornig. (1 Reply)
Discussion started by: neeraj617
1 Replies

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

7. Shell Programming and Scripting

Attaching two text files in two different sheet in same excel

Hi, My requirement is to get attach two different text file contents to two different sheets in same excelsheet. Also, is there any way we can name the tabs as desired ? Kindly assist. (2 Replies)
Discussion started by: sanjaydubey2006
2 Replies

8. Shell Programming and Scripting

Filter data in Excel sheet using Shell Script

Hi, I have an excel sheet which has 100000 records. All these records are having 3 columns each with the last column as "Y" or "N". I would like to filter those records which has the value "Y". Can you please let me know how to proceed with that? Thanks in advance. -Sri ----------... (8 Replies)
Discussion started by: bhanusri83
8 Replies

9. Shell Programming and Scripting

How to update existing excel sheet using shell script

Hi All, I am having an excel sheet with pre-defined format which our business team specified, what i need to do is i have to write a script which need to pick values from database and update specified cells in excel sheet.. can any one please help me in this regard.. I am able to pull the... (3 Replies)
Discussion started by: balanarendra
3 Replies

10. UNIX for Dummies Questions & Answers

Script to generate text file from excel file

Hello, I have a excel file which has almost ten columns on the shared drive. I have to write a shell script to ftp that daily to unix server and then extract some columns from there and generate oracle standard text file. The columns should be in proper order and aligned properly, otherwise... (1 Reply)
Discussion started by: isingh786
1 Replies
Login or Register to Ask a Question