Count same string count out of massive string list - c# -



Count same string count out of massive string list - c# -

i have got on 600k lines of string. want grouping same strings , larn counts.

so example

i go school music games music music games music

so result be

i go school , 1 games , 2 music , 4

how can fastest possible way. c# 4.0 give thanks you.

the groupby method want. you'll need strings in list or implements ienumerable<string>. file.readlines suggested spender homecoming ienumerable<string> reads file line line.

var stringgroups = file.readlines("filename.txt").groupby(s => s); foreach (var stringgroup in stringgroups) console.writeline("{0} , {1}", stringgroup.key, stringgroup.count());

if want them in order of to the lowest degree (as in example) add together orderby

... foreach (var stringgroup in stringgroups.orderby(g => g.count())) ...

c# string list grouping group

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -