Created
December 17, 2017 22:30
-
-
Save capJavert/f664182c677c44e172d4c97fdbb3c442 to your computer and use it in GitHub Desktop.
ints-assignment-3-parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xlsxwriter | |
import sys | |
args = sys.argv | |
workbook = xlsxwriter.Workbook(args[1]) | |
worksheet = workbook.add_worksheet() | |
# Some data we want to write to the worksheet. | |
data = [ | |
# ['S1', 'C1', 'S2', 'C2', 'S3', 'C3', 'S4', 'C4', 'S5', 'C5', 'CLASS'], | |
['S1', 'S2', 'S3', 'S4', 'S5', 'CLASS'], | |
] | |
filename = args[2] | |
file = open(filename, "r") | |
for line in file.read().splitlines(): | |
line = [int(i) for i in line.split(",")] | |
item = [] | |
for i in range(10, step=2): | |
item.append(line[i]*line[i+1]) | |
item.append(line[-1]) | |
data.append(item) | |
worksheet.write(0, 0, '// ~->[CASE-1]->~') | |
row = 1 | |
for item in data: | |
for col in range(6): | |
worksheet.write(row, col, item[col]) | |
row += 1 | |
workbook.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment