From 0982a21592b0b619e397191f3671063ede170066 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Tue, 2 Feb 2016 08:45:37 +0300 Subject: [PATCH] 2digits numbering for subjects --- opytex/opytex.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opytex/opytex.py b/opytex/opytex.py index 6f6a636..ced938a 100755 --- a/opytex/opytex.py +++ b/opytex/opytex.py @@ -47,12 +47,13 @@ def produce_and_compile(options): output = path(template_file.dirname()) / path(template_file.name[3:]) if not options.csv_file: - list_infos = [{"num": i+1} for i in range(options.num_subj)] + # {:02:0f} means that we want a 2 digits number + list_infos = [{"num": "{:02.0f}".format(i+1)} for i in range(options.num_subj)] else: with open(options.csv_file, 'r', encoding = 'ISO-8859-1') as f: list_infos = list(csv.DictReader(f, delimiter=";")) for (i,a) in enumerate(list_infos): - a['num'] = i+1 + a['num'] = "{:02.0f}".format(i+1) if output.dirname() != "": output.dirname().cd()