I want to test againts multiple command line arguments in a loop
> python Read_xls_files.py group1 group2 group3
No this code tests only for the first one (group1).
hlo = []
for i in range(len(sh.col_values(8))):
if sh.cell(i, 1).value == sys.argv[1]:
hlo.append(sh.cell(i, 8).value)
How should I modify this that I can test against one, two or all of these arguments? So, if there is group1 in one sh.cell(i, 1), the list is appended and if there is group1, group2 etc., the hlo is appended.
You can iterate over sys.argv[1:]
, e.g. via something like:
for grp in sys.argv[1:]:
for i in range(len(sh.col_values(8))):
if sh.cell(i, 1).value == grp:
hlo.append(sh.cell(i, 8).value)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With