String trend-analysis (suggestions for data structure)


I want to keep track of strings from text files over time (reading them in). What would be the best method to programmatically keep track? This is the desired end result after 3 entries.

String|frequency|date-Col1|date-Col2|..date-Col N|
==================================================
hello | 2       | 1/1/16  | 3/5/16  |
motto | 1       | 2/3/16

Some ideas I'm kicking around: using python dictionaries, java arrayLists, R?

Any suggestions, thanks?

Answer

from collections import defaultdict

words_seen = defaultdict(list)

for word,filedate in get_words():
    words_seen[word].append(filedate)

then frequency is len(words_seen[word]).

source: stackoverflow.com
js interview questions