Last active
January 12, 2016 01:47
-
-
Save cjauvin/a9beae44ab335ebf1c4e to your computer and use it in GitHub Desktop.
This file contains 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 argparse | |
from pyexcel_ods3 import get_data | |
import random | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser('Generateur pour Ariel') | |
parser.add_argument( | |
'-n', default=5, type=int, help='nombre de paragraphes' | |
) | |
parser.add_argument( | |
'-p', nargs=2, default=(2, 5), type=int, | |
help='longueur des paragraphes' | |
) | |
args = parser.parse_args() | |
data = get_data("GR_AN_V1.ods")['Feuille1'] | |
paras = [] | |
for i in range(args.n): | |
n_para_cells = random.randint(args.p[0], args.p[1]) | |
para = [] | |
while len(para) < n_para_cells: | |
row = random.randint(1, len(data) - 1) | |
col = random.randint(0, len(data[row]) - 1) | |
cell = data[row][col].strip() | |
if not cell: | |
continue | |
para.append(cell) | |
paras.append(para) | |
for para in paras: | |
print(', '.join('"%s"' % cell for cell in para)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment