Convert c file to csv file(unix format) in python
umasrinath88 at gmail.com
umasrinath88 at gmail.com
Tue May 19 13:14:58 EDT 2015
On Tuesday, May 19, 2015 at 10:15:43 PM UTC+5:30, Mihamina Rakotomandimby wrote:
> On 05/19/2015 07:30 PM, umasrinath88 at gmail.com wrote:
> > Can anyone help me in converting .c file to csv file (unix format).
> >
> >
> Would you give a sample?
Hi Mihamina,
I have sent you the complete work folder.
thyncHextoC.py is python script used to convert .hex to .c structure file
Open command prompt window and type below command.
>python thyncHextoC.py <mention hex file to be converted>
example: python thyncHextoC.py 18052015_1640_STM_5_08_DVT.hex
stm32Image.c file is created.
this .c file has to be converted to csv file.
I was following manual steps as below:(But want to automate now)
3)Open stm32Image.c file in notepad++
Delete first 23 lines of data in the file(including this line "const flashImage_t flashImageData[] ={")
The .C file must contain only hex bytes now.
4)Select all the hex bytes and go to edit option->Blank operation-> Remove leading and trailing spaces
next go again edit option->Line operations-> Remove empty lines containing blank characters
Remove the comma(,) from last hex byte till end of the file.
This can be achieved using Alt+Shift+end and scroll down until the last hex byte.
Note:Donot modify last line 0,0,0 }; of the file. Let it remain as it is.
5)Once all the above steps are done, Save the file and in command prompt execute below command for converting .c to .csv file
>ren stm32Image.c <file name.csv>
example:ren stm32Image.c 28022015_1140_EVT.csv
More information about the Python-list
mailing list