Operating environment
ideone (Python 3.5)
--Operation test data is in csv format
--I want to format it like {0, 3, 0}, {100, 3, 0}, ...
--I want to use it with the embedded C source
It takes time to manually create the above format.
Note: ** As of April 18, 2018, ideone errors occur frequently **
https://ideone.com/yN0wSe
# change [NUM_COLUMN]
NUM_COLUMN = 3
# paste from Excel sheet
data="""0 3 0
100 3 0
200 3 0
300 3 0
400 3 0
500 3 0
"""
for aline in data.split('\n'):
elem = aline.split('\t')
if len(elem) < NUM_COLUMN:
break
print("{%s,%s,%s}," % (elem[0], elem[1], elem[2]), end='')
run
{0,3,0},{100,3,0},{200,3,0},{300,3,0},{400,3,0},{500,3,0},
Recommended Posts