Is there any script which convert binary file to CSV format

Dear guys;
I have a binary file and I need to convert its data to csv format ...appreciating your help.

Best Regards

You'll have to be more specific on what you have. What kind of binary file? Is the format documented somewhere? If not, can you describe it? What kind of data is in that file?

I have do the file command and the output is:

Note:- I have SunOS solaries 8.

file /opt/CiscoMGC/var/bam/cdr_20091102153450_576587.bin

/opt/CiscoMGC/var/bam/cdr_20091102153450_576587.bin:    data

Is it possible to upload a copy of the file? How big is it?

It might be helpful to do an

od -c | more 

on the file. That will help you see whats in there that you might be able to use.

A "strings" could also be useful.

the file is uploaded guys in attached.

BR

Any help please...:o

How should we be able to help you. All you've told us yet is that you have that file and that you want to convert it to CSV. We don't know what format that file is in. We don't know where to look for the data you want, what kind of data that is, what format it is in. We don't know how much of that information you want in the CSV, or if there should be any transformations applied. We don't even know what you've tried so far, if any.

So, if you want our help, help yourself by giving us enough information so that we can understand your problem.

Hi Ahmad, how about:

strings cdr_20091102155050_576591.bin|
awk 'NR>2{if(k==""){k=$1;rec=k} else{rec=rec","$1; if(k==$1){if(k!=p){k="";print rec}}} p=$1}'
21622727582,21622727582,962799607810,962799607810,rttrnk-gwmsc1,rtlist-gwmsc1,213.177.163.34,10.100.3.50,/83d7b75d28a98811bc6e62deeb3e4358@213.177.163.34,213.177.163.34,213.177.167.82,10.100.6.22,G729,G729,43868,49452,21622727582
213770980158,213770980158,962796737788,962796737788,rttrnk-gwmsc2,rtlist-gwmsc2,213.177.163.34,10.100.3.50,/f55d42f798bb2d23769ba27b5f8897c9@213.177.163.34,213.177.167.18,10.100.6.50,G729,52740,49328,213.177.163.34,213770980158
962785150116,962785150116,966555816513,966555816513,rttrnk-bt,rtlist-bt,962555816513,962795364491,10.100.3.50,194.88.66.181,*7b6d83e3-474b4fcf-2bed7545-25d@10.100.3.50,962555816513,962785150116
21623272448,21623272448,962799269490,962799269490,rttrnk-gwmsc1,rtlist-gwmsc1,213.177.163.34,10.100.3.50,/822f6d69e6fb7054a4b9d06ab50397c4@213.177.163.34,213.177.163.34,213.177.167.82,10.100.6.22,G729,G729,57300,49456,21623272448
249912279033,249912279033,249912010584,249912010584,rttrunk-sudan,rtlist-sudan,96249912010584,10.100.3.50,41.223.203.244,*2b06f487-342a99f3-53530cd2-25e@10.100.3.50,10.100.5.46,UNKNOWN,UNKNOWN,49262,249912279033
7088986757,7088986757,96264888716,96264888716,rttrnk-gwmsc2,rtlist-gwmsc2,216.53.4.5,10.100.3.50,Esbcsipuac.2_66.33.165.74_b09sb07_1_2009110209292117_1900037343_356308,66.33.165.73,10.100.6.50,G729,20038,49330,216.53.4.5,7088986757

Well here is the contents of the archive, how do you need it converted to csv format?

 MGC-CDR-PGW1A
9.5(2)
21622727582
21622727582
962799607810
962799607810
rttrnk-gwmsc1
rtlist-gwmsc1
213.177.163.34
10.100.3.50
/83d7b75d28a98811bc6e62deeb3e4358@213.177.163.34
213.177.163.34
213.177.167.82
10.100.6.22
G729
G729
43868
49452
21622727582
213770980158
213770980158
962796737788
962796737788
rttrnk-gwmsc2
rtlist-gwmsc2
213.177.163.34
10.100.3.50
/f55d42f798bb2d23769ba27b5f8897c9@213.177.163.34
213.177.167.18
10.100.6.50
G729
52740
49328
213.177.163.34
213770980158
962785150116
962785150116
966555816513
966555816513
 rttrnk-bt
 rtlist-bt
962555816513
962795364491
10.100.3.50
194.88.66.181
*7b6d83e3-474b4fcf-2bed7545-25d@10.100.3.50
962555816513
962785150116
21623272448
21623272448
962799269490
962799269490
rttrnk-gwmsc1
rtlist-gwmsc1
213.177.163.34
10.100.3.50
/822f6d69e6fb7054a4b9d06ab50397c4@213.177.163.34
213.177.163.34
213.177.167.82
10.100.6.22
G729
G729
57300
49456
21623272448
249912279033
249912279033
249912010584
249912010584
rttrunk-sudan
rtlist-sudan
96249912010584
10.100.3.50
41.223.203.244
*2b06f487-342a99f3-53530cd2-25e@10.100.3.50
10.100.5.46
UNKNOWN
UNKNOWN
49262
249912279033
7088986757
7088986757
96264888716
96264888716
rttrnk-gwmsc2
rtlist-gwmsc2
216.53.4.5
10.100.3.50
Esbcsipuac.2_66.33.165.74_b09sb07_1_2009110209292117_1900037343_356308
66.33.165.73
10.100.6.50
G729
20038
49330
216.53.4.5
7088986757
 MGC-CDR-PGW1A
9.5(2)

dear steadyonabix ;
how did you convert the file to txt.
BR

Good Morning :)The only free utility I know of for unzipping rar archives is WinRAR: -http://download.cnet.com/WinRAR-32-bit/3000-2250_4-10007677.htmlOnce unzipped the resulting BIN file was passed to strings to give the above output. It should be a simple matter from there to convert it to CSV format.Good luck

I also unrarred it on windows, transferred it to unix and used strings to feed the text content into my awk script above.

thanks guys :):):slight_smile:

urar

Unrar - Wikipedia, the free encyclopedia