If this input exists in a specific row, for example DD in row WORD4
(row 3), the program will then ask them to enter an integer and if this is over a certain number it will write it including the line.
Something like so:
a0,a1,a2,a3,a4
JA,BV,PA,DD,6
The error received I did receive was:
TypeError: writerows() takes exactly one argument (2 given)
And
TypeError: can only concatenate list (not "str") to list
Thanks to Joel Johnson and Stevieb for the solution to this problem!
The solution is as followed, Thanks Joel Johnson:
First, you need to use
with open('CSVFile2.csv', 'a') as f:
to write anything to the file(if you want to keep any content already inCSVFile2.csv
or use'w'
if you want to overwrite it).Second, since you are only trying to write one row with format
['JA',BV','PA','DD','6']
usewriter.writerow()
instead ofwriter.writerows()
else you will end up withJ,A,B,V,P,A,D,D,6
as your output.Third, simply append
integer_input
torow
before passing it towriter.writerow()
also note that it needs to be in str() formatIf you have any other questions I would refer you to the docs here
example: