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

is the file tab separated or space separated ?

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

cp file-name file-name.bk
sed -i 's/ /,/g' file-name

Or using tr

cat inputfile.txt | tr ' ' ',' >outputfile.csv

This is Useless Use of Cat.

tr ' ' ','  < inputfile.txt > outputfile.csv

Right Franklin52 !

i forgot about the cat because my first try was :

egrep -v '^$|^#' inputfile.txt | tr ' ' ',' >outputfile.csv 

sorry for my mistake :slight_smile:

Hi

Thanks for your reply ...Its working But Client also needs

{It also might be worth running an error check for the number of "commas" in each line of the created csv file.
There should be 5 commas in every line of the csv file. If there are less or more that this then the script should log an error and preferably rename the created file to .err (for example).}
could you please help me on this ..Thanks

---------- Post updated at 05:53 AM ---------- Previous update was at 05:51 AM ----------

Thanks for code..it working ..Client also needs
---
It also might be worth running an error check for the number of "commas" in each line of the created csv file.
There should be 5 commas in every line of the csv file. If there are less or more that this then the script should log an error and preferably rename the created file to .err (for example).
request you to add additional code