-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
executable file
·24 lines (17 loc) · 899 Bytes
/
generate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
import argparse
def gen_code(index):
return chr(ord('A') + index/26) + chr(ord('A') + index%26)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Generate input data.')
parser.add_argument('csv', metavar='OUTPUT', nargs=1, help='output file name')
parser.add_argument('-r', '--rows', default=10, type=int, help='number of rows')
parser.add_argument('-c', '--cols', default=10, type=int, help='number of columns')
args = parser.parse_args()
with open(args.csv[0], 'w') as output:
output.write(','.join([gen_code(ii) for ii in range(args.rows)]) + '\n')
output.write(','.join([gen_code(ii).lower() for ii in range(args.rows)]) + '\n')
base = 0
for ii in range(args.rows):
output.write(','.join([str(base + ii) for ii in range(args.cols)]) + '\n')
base += args.cols