Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string[] files = Directory.GetFiles("", "*.json", SearchOption.TopDirectoryOnly);
- DateTime now = DateTime.Now;
- Dictionary<string, int> names = new Dictionary<string, int>();
- foreach (string file in files)
- {
- Thread thread = JsonConvert.DeserializeObject<Thread>(File.ReadAllText(file));
- if ((now - thread.Posts.First().DateTime).TotalDays >= 7)
- continue;
- foreach (Post post in thread.Posts)
- {
- string name = post.Name + post.Trip;
- if (!names.ContainsKey(name))
- names.Add(name, 1);
- else
- names[name]++;
- }
- }
- names = names.OrderBy(kv => kv.Value).Where(kv => kv.Value > 100).ToDictionary(kv => kv.Key, kv => kv.Value);
- foreach (var kv in names)
- Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
- Console.WriteLine("{0} total", names.Count);
Advertisement
Add Comment
Please, Sign In to add comment