Reputation: 45
head = csv.reader(open("header.csv"))
I have something like this. here is it possible to provide part of the input in the command line like this.
head = csv.reader(open("sys.argv[1]".csv"))
So that I can launch the script as
python test.py header
Upvotes: 0
Views: 42
Reputation: 1236
Since python 3.6 you can use f-strings. https://www.python.org/dev/peps/pep-0498/
head = csv.reader(open(f'{sys.argv[1]}.csv'))
Upvotes: 1
Reputation: 12157
head = csv.reader(open('{}.csv'.format(sys.argv[1])))
or in python 3.6 or later
head = csv.reader(open(f'{sys.argv[1]}.csv'))
Upvotes: 1