I want to append a list of values at the end of each row of a csv file except the header.
I have tried following code but it deletes all the rows from csv file and does not appends any value to the csv file.
import tensorflow
from fer.fer import FER
import cv2
from os import listdir
from os.path import isfile, join
import numpy
import csv
f1 = open("C:/Yasir/Thesis/4/FaceDetectionLatest/bin/Debug/Data/demoScoringData9.csv", "a+")
reader = csv.reader(f1)
images = numpy.empty(len(onlyfiles), dtype=object)
for n in range(0, len(onlyfiles)):
images[n] = cv2.imread( join(mypath,onlyfiles[n]) )
# cv2.imshow(join(mypath,onlyfiles[n]),0)
img = cv2.imread( join(mypath,onlyfiles[n]) )
detector = FER()
emotion = detector.detect_emotions(img)
dict = emotion[0]
emoList = dict['emotions']
dict_writer = csv.DictWriter(f1, emoList)
dict_writer.writerow(emoList)
I want to append the following values to a csv file which is already created. I mean the dict values should be appended to each row of csv except the header values like below.
{'angry': 0.15, 'disgust': 0.0, 'fear': 0.05, 'happy': 0.06, 'sad': 0.24, 'surprise': 0.02, 'neutral': 0.49}
I am also sharing the screenshot of my csv file screenshot