Convert c file to csv file(unix format) in python

umasrinath88 at gmail.com umasrinath88 at gmail.com
Tue May 19 15:26:05 EDT 2015


On Tuesday, May 19, 2015 at 11:51:20 PM UTC+5:30, Denis McMahon wrote:
> On Tue, 19 May 2015 09:30:15 -0700, umasrinath88 wrote:
> 
> > I have a python script file which converts .hex file  to c file.
> 
> Hex is generally an ascii file containing hexadecimal values.
> 
> .c is generally an ascii file formatted in a way that corrsponds to the 
> structures of the c programming language.
> 
> > Can anyone help me in converting .c file to csv file (unix format).
> 
> csv is generally a way of exchanging data between different software 
> applications in a generally human readable format.
> 
> I'm unsure as to the translations you expect to be made to convert a .c 
> file into a csv file. Perhaps you could elaborate on these.
> 
> -- 
> Denis McMahon, denismfmcmahon at gmail.com

Hi Denis,

I agree to you point.

I have shared c file with you.Iorder to convert to unix format csv, below are the main steps we can follow.

1 Remove the 23 first lines
2.Remove all empty lines
3.Remove spaces at the beginning of each line
4.Replace ,\r\r\n with \n [commaCRCRLF replace with LF]
5.Rename and save this file as csv.

Can you help me in writing a python code for this. Which takes stm32Image.c file as input and generates stm32Image.csv

Regards,
Uma



More information about the Python-list mailing list