Conversion of below Tabs Tex file into CSV format file : shell script needed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Conversion of below Tabs Tex file into CSV format file : shell script needed
# 1  
Old 04-29-2011
Conversion of below Tabs Tex file into CSV format file : shell script needed

Request if some one could provide me shell script that converts the below "input file" to "CSV format file" given

Name Domain Contact Phone Email Location
----------------------- ------------------------------------------------ ------- ----- --------------------------------- -------------------
clients / 5fdf97049abdd582976d954bba8ff256c4beedd8
GEN-I / Service Provider
MC_RETIRED / acb53a6470ba5fdd6efc93a0d7228e9e014a199e
REPLICATE / 5cf5275db7ceb0a7c8e29c7d66fd548f61ced14d
CUSTOMER_01 /GEN-I <<Cust01 PARTY NUMBER>>
CUSTOMER_02 /GEN-I <<Cust02 PARTY NUMBER>>
RCB_INSTANCE_01 /GEN-I/CUSTOMER_01 "Product Instance 01 Description" <<Cust01_Inst01 PRODUCT ID>>
RCB_INSTANCE_02 /GEN-I/CUSTOMER_01 "Product Instance 02 Description" <<Cust01_Inst02 PRODUCT ID>>
RCB_INSTANCE_01 /GEN-I/CUSTOMER_02 " Product Instance 01 Description" <<Cust02_Inst01 PRODUCT ID>>
wn1naeavu101.sdp.net.nz /REPLICATE 1eb4ad6f161e2be6644c13270adaa8dc7e7aa6a8
clients /REPLICATE/wn1naeavu101.sdp.net.nz d93a694ed05147f8f9895ffa57fb91a0b15ed25d
GEN-I /REPLICATE/wn1naeavu101.sdp.net.nz a4af9e4cc65ba65550b3365759280cf1197cb7da
MC_RETIRED /REPLICATE/wn1naeavu101.sdp.net.nz 892e8133bb46f16caeb4667811457e5a9126838c
REPLICATE /REPLICATE/wn1naeavu101.sdp.net.nz b983f7c9a69545b4f0a63a30f28447279a4524c2
WLGtest /REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I 4d6c41eb132caae70e8a9f990201e5c83c1104b5
RCB_INSTANCE_01 /REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I/CUSTOMER_02 0aec9c024ae8c9b60a81a371980e58be0eb2f27e
RCB_INSTANCE_02 /REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I/CUSTOMER_03 95e059107f165bb603aabae42b59c8f51e64e855

CSV format file :

Name,Domain,Contact,Phone,Email,Location
-----------------------,------------------------------------------------,-------,-----,---------------------------------,----------------------------------------
clients,/,,,,5fdf97049abdd582976d954bba8ff256c4beedd8
GEN-I,/,,,,Service Provider
MC_RETIRED,/,,,,acb53a6470ba5fdd6efc93a0d7228e9e014a199e
REPLICATE,/,,,,5cf5275db7ceb0a7c8e29c7d66fd548f61ced14d
CUSTOMER_01,/GEN-I,,,,<<Cust01 PARTY NUMBER>>
CUSTOMER_02,/GEN-I,,,,<<Cust02 PARTY NUMBER>>
RCB_INSTANCE_01,/GEN-I/CUSTOMER_01,,,"Product Instance 01 Description",<<Cust01_Inst01 PRODUCT ID>>
RCB_INSTANCE_02,/GEN-I/CUSTOMER_01,,,"Product Instance 02 Description",<<Cust01_Inst02 PRODUCT ID>>
RCB_INSTANCE_01,/GEN-I/CUSTOMER_02,,,"Product Instance 01 Description",<<Cust02_Inst01 PRODUCT ID>>
wn1naeavu101.sdp.net.nz,/REPLICATE,,,,1eb4ad6f161e2be6644c13270adaa8dc7e7aa6a8
clients,/REPLICATE/wn1naeavu101.sdp.net.nz,,,,d93a694ed05147f8f9895ffa57fb91a0b15ed25d
GEN-I,/REPLICATE/wn1naeavu101.sdp.net.nz,,,,a4af9e4cc65ba65550b3365759280cf1197cb7da
MC_RETIRED,/REPLICATE/wn1naeavu101.sdp.net.nz,,,,892e8133bb46f16caeb4667811457e5a9126838c
REPLICATE,/REPLICATE/wn1naeavu101.sdp.net.nz,,,,b983f7c9a69545b4f0a63a30f28447279a4524c2
WLGtest,/REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I,,,,4d6c41eb132caae70e8a9f990201e5c83c1104b5
RCB_INSTANCE_01,/REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I/CUSTOMER_02,,,,0aec9c024ae8c9b60a81a371980e58be0eb2f27e
RCB_INSTANCE_02,/REPLICATE/wn1naeavu101.sdp.net.nz/GEN-I/CUSTOMER_03,,,,95e059107f165bb603aabae42b59c8f51e64e855

Last edited by sreenath1037; 04-29-2011 at 03:39 AM..
# 2  
Old 04-29-2011
is the file tab separated or space separated ?
# 3  
Old 04-29-2011
The File is spaces separated :Example for first three rows.,

Name Domain Contact Phone Email Location
----------------------- ------------------------------------------------ -------

clients / 5fdf97049abdd582976d954bba8ff256c4beedd8
GEN-I / Service Provider
MC_RETIRED / b53a6470ba5fdd6efc93a0d7228e9e014a199e
# 4  
Old 04-29-2011
Code:
cp file-name file-name.bk
sed -i 's/ /,/g' file-name

# 5  
Old 04-29-2011
Or using tr
Code:
cat inputfile.txt | tr ' ' ',' >outputfile.csv

# 6  
Old 04-29-2011
Quote:
Originally Posted by Chirel
Or using tr
Code:
cat inputfile.txt | tr ' ' ',' >outputfile.csv

This is Useless Use of Cat.
Code:
tr ' ' ','  < inputfile.txt > outputfile.csv

# 7  
Old 04-29-2011
Right Franklin52 !

i forgot about the cat because my first try was :
Code:
egrep -v '^$|^#' inputfile.txt | tr ' ' ',' >outputfile.csv

sorry for my mistake Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python or Shell script to Grep strings from input file and output in csv format

Hi Experts, I am writing a python script to grep string from file and display output in csv file as in attached screenshot https://drive.google.com/file/d/1gfUUdfmQma33tz65NskThYDhkZUGQO0H/view Input file(result_EPFT_config_device) Below is the python script i have prepared as of... (1 Reply)
Discussion started by: as7951
1 Replies

2. Shell Programming and Scripting

Help with Shell Scrip in Masking particular columns in .csv file or .txt file using shell script

Hello Unix Shell Script Experts, I have a script that would mask the columns in .csv file or .txt file. First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder. Two parameters are passed ... (5 Replies)
Discussion started by: Mahesh G
5 Replies

3. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

4. Shell Programming and Scripting

Format CSV file from a shell script

I have a shell script which creates a CSV files. there are 3 fields, field1, field2 and comp. I will generates the values for field1 and field2 and Want to compare both. If field1>filed2 then comp should be success written in green in CSV file, else it should fail in red color. How can I change the... (5 Replies)
Discussion started by: sauravrout
5 Replies

5. Shell Programming and Scripting

conversion of spaces into CSV format file

INput file attached in thread : Column widths at 24,73,82,87,121 characters (sed 's/./,/24;s/./,/73;s/./,/81;s/./,/87;s/./,/121;s/ *, */,/g' fixedinputfile >output.csv ). The client wants instead of hard coding the column widths as they are not fixed .he has given the hint stating that ( ... (3 Replies)
Discussion started by: sreenath1037
3 Replies

6. Shell Programming and Scripting

Conversion of spaces Text file into CSV format file

Input file (each line is separaed by spaces )given below: Name Domain Contact Phone Email Location ----------------------- ------------------------------------------------ ------- -----... (18 Replies)
Discussion started by: sreenath1037
18 Replies

7. Shell Programming and Scripting

shell or perl script needed for ldif file to text file conversion

This is the ldf file dn: sdcsmsisdn=1000000049,sdcsDatabase=subscriberCache,dc=example,dc=com objectClass: sdcsSubscriber objectClass: top postalCode: 29600 sdcsServiceLevel: 10 sdcsCustomerType: 14 givenName: Adelia sdcsBlackListAll: FALSE sdcsOwnerType: T-Mobile sn: Actionteam... (1 Reply)
Discussion started by: LinuxFriend
1 Replies

8. Shell Programming and Scripting

Shell script for CSV conversion

thanks for allowing me join your forum i have an output of linux command "who" which provides following details..... CURRENT USER/ACCT INFO 17:31:36 up 4:49, 4 users, load average: 0.03, 0.04, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root :0 - 12:59 ?xdm? 4:54 0.02s /bin/sh /usr/bi... (1 Reply)
Discussion started by: ayyappancheta
1 Replies

9. UNIX for Dummies Questions & Answers

two csv file in an excel file in two tabs

Hi, I was wondering if anybody could help me with this. I have two .csv file that I need to put it in an excel file in two different tabs using Shell Script. Thanks in advance. JP (7 Replies)
Discussion started by: JPalt
7 Replies

10. UNIX for Advanced & Expert Users

format csv file using shell script

i have a report.csv file from oracle datavase In that file data is like this with report heading and date SALES DAILY REPORT DATE: 06-26-2007 REPORT NAME: SALES DATA AA.BB.CCCC.DDDD,BBBBB,06-26-2007,0,BEGIN,END ZZ.VV.DDDD.XXXXXXX,MMMMMM,06-25-2007,18,BEGIN,END... (3 Replies)
Discussion started by: raosurya
3 Replies
Login or Register to Ask a Question