I am having an issue with the following section of Python code:
# Open/Create the output file
with open(sys.argv[1] + '/Concatenated.csv', 'w+') as outfile:
try:
with open(sys.argv[1] + '/MatrixHeader.csv') as headerfile:
for line in headerfile:
outfile.write(line + '\n')
except:
print 'No Header File'
Specifically the error is as follows:
Traceback (most recent call last):
File "ConcatenateFiles.py", line 12, in <module>
with open(sys.argv[1] + 'Concatenated.csv', 'w+') as outfile:
IndexError: list index out of range
I've done some research and it seems that the sys.argv
might require an argument at the command line when running the script, but I'm not sure what to add or what the issue might be! I've also searched the site, but all of the solutions I've found either have no comments and/or don't include the open function as mine does.