C#: Generating a table from a .CSV that counts name (string) occurences in another table -


i importing data table .csv file headers, , no problem.
let call file dt.csv.

one column header named companyname.

but need create new table i, first of all, list companies first data table , count how many times each companyname appear in first table.

the first table can have 500 5000 lines, number of different companies appearing 15-50. challenge not know company names expect in advance, cannot make positive list count against. need list count against generated based on content of column companyname (so not duplicates of same name).

this code c# largely pseudocode i'm not of approach reading / writing csv file:

var seencompanies = new list<string>(); foreach(var line in csvfile) {     seencompanies.add(line.getcolumn("companyname")); }  var companiesandcounts =      seencompanies     .groupby(s => s)     .select(group => new { name = group.key, count = group.count()})     .tolist();  foreach(var group in companiesandcounts) {     outputfile.write(group.name + "," + group.count); } 

this pretty standard conceptually, you're doing counting occurrences of each distinct company name , writing out.

you can adapt better suit needs, should enough show how can approached.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -