%cat test2.py
#! /usr/bin/env python
import re
pre = """enum MenuExeId\n{\n\tmnux"""
post = """};"""
buf = ""
result = []
for line in open( 'test.csv' ).readlines():
line = line.replace( '"', "" ).split( "," )
result = result + line[ -1: ]
buf = ''.join( result )
buf = pre + re.sub( "\n(?=.\w)", ",\n\tmnux", buf ) + post
print buf
%python test2.py
enum MenuExeId
{
mnuxStart
mnuxStop
mnuxReset
mnuxCounts
mnuxStorage
mnuxSettings
mnuxGPS
mnuxAccel
mnuxFilter
};
I used string -> list -> string this time.
No comments:
Post a Comment