2digits numbering for subjects

This commit is contained in:
Benjamin Bertrand 2016-02-02 08:45:37 +03:00
parent d864808774
commit 0982a21592

View File

@ -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()