python 3.x - How do I add a new row at the end of my csv file? Getting tablewrite.writerow(new_field) io.UnsupportedOperation: not writable error -


import csv import os  print("the current working directory {}" .format(os.getcwd()))    open('laliga.csv', newline='') csvfile:     tableread = csv.reader(csvfile, delimiter=',')     row in tableread:         print(row)     print('---------')   new_field = ['20', 'srh', '3', '2', '5', '2', '7', '3', '4', '7', 'wwlw'] open('laliga.csv', newline='') csvfile:     tablewrite = csv.writer(csvfile, dialect='excel', delimiter=' ')     in range(20):         tablewrite.writerow(new_field) 

i add new row called new_field @ end of csv file. can change specific row column values. ex:row[2],col[5] = 23

['no', 'team', 'mp', 'w', 'd', 'l', 'f', 'a', 'd', 'p', 'last 5 matches']

['1', 'real madrid', '29', '22', '5', '2', '78', '30', '48', '71', 'wwwww']

['2', 'barcelona', '30', '21', '6', '3', '88', '26', '62', '69', 'wwwlw']

.....................so on till 19.......i want add new 20th row


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -