Created
January 12, 2016 01:39
-
-
Save cjauvin/371c0f41e2a711f4eabe 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'] | |
n_data = len(data) | |
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: | |
a = random.randint(1, n_data - 1) | |
b = random.randint(0, len(data[a]) - 1) | |
cell = data[a][b] | |
if not cell: | |
continue | |
para.append(data[a][b]) | |
paras.append(para) | |
for p in paras: | |
print(', '.join('"%s"' % c for c in p), end='\n\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment