import pandas as pd
import csv,sched,nltk,arrow
from time import perf_counter
def ngram_search():
#code here
item['length']=len(word_tokenize(s)) # number
item['time edit']=arrow.utcnow().shift(hours=-1).humanize().upper() # text
item['top1'] = "word"
return item
path=r"C:\Users\Sublime Text\products.csv"
df = pd.read_csv(path)
saved_column = df['Name of Product']
for i in saved_column:
name=i.replace(",","+").replace(";","+")
item=ngram_search(name)
#update csv file here add the columns of items to the csv file
I am trying to add to an existing csv file (15 columns, 283216 row), the function returns a dictionary of 3 values. Is there a way to directly update the csv file without rewriting it?