I'm accessing my python script in $SPLUNK_HOME/bin via command line (in a VM) to see if the code runs correctly. Whenever I run the file outside of commandline, the code works perfectly, but when I run it in the commandline, it gives me this error:
Traceback (most recent call last):
File "demo.py", line 105, in
parse_cert_csv('qualys.csv')
File "demo.py", line 82, in parse_cert_csv
with open(FILENAME, 'w', newline='') as csvfile:
TypeError: 'newline' is an invalid keyword argument for this function
My writing-to-file code looks like this:
with open(FILENAME, 'w', newline='') as csvfile:
keys = list(rows[0].keys()) #keys are the header
dict_writer = csv.DictWriter(csvfile, fieldnames=keys)
dict_writer.writeheader()
dict_writer.writerows(rows)#rows is the data I want to write to the file
Does it matter that my code doesn't work in the command line? And if so, how can I fix it?
↧