How to add characters at the end of the string in python?

Hello. Prompt how correctly to write script, to add at the end of specific lines of desired characters?

Code like this:
ARRAY = [['text1', 20], ['text2', 21]]
file_stat = open('text.csv', 'a+')
line_stat = file_stat.readlines()

for item in ARRAY:
 count = 'then the row count for the search item[0]'
// here I tried a few different options
 line_stat[item[1]] = line_stat[item[1]].rstrip('/n') + ',' + str(count) + '\n'
 file.write(line[item[1]])


It is necessary in the line below the number specified in the array, at the end of the line add a comma and the number of rows, which turned out to calculate. But instead simply added a new line.
March 19th 20 at 09:07
1 answer
March 19th 20 at 09:09
You opened the file with a key, a+ - reading and adding to the end of the file. Therefore, the file is read and the row of dobavlyayut in the end.

Also, you clearly are trying to create some sort of Bicycle pornography. Your task is to work with the csv needs to help the pandas library
Now would be 3rd party Libu pull to write to a file a pair of values separated by comma - jerel66 commented on March 19th 20 at 09:12

Find more questions by tags Python