Given a comma-delimited file like this example:

"92528","1","36","38280","51801","PLANT 5 - LINE 1","37",
"92528","1","8","37450","51801","PLANT 5 - LINE 1","37",
"92528","2","8","37896","51801","PLANT 5 - LINE 1","37",
"92528","3","8","37450","51801","PLANT 5 - LINE 1","37",
"92528","61","32","37450","51802","PLANT 5 - LINE 2","37",
"92528","62","16","38721","51802","PLANT 5 - LINE 2","37",
"92528","63","8","38722","51802","PLANT 5 - LINE 2","37",
"92528","64","4","37450","51802","PLANT 5 - LINE 2","37",
"92528","149","8","37450","51804","PLANT 5 - LINE 4","37",
"92528","150","2","38668","51804","PLANT 5 - LINE 4","37",
"92528","151","8","37450","51804","PLANT 5 - LINE 4","37",
"92528","152","2","38668","51804","PLANT 5 - LINE 4","37",

I need to sort it first by the 6th field of each line ("PLANT 5 - LINE 1" on the first line),
then by the 4th field of each line ("38280" on the first line); then I need to get a subtotal for each item in the 4th field so that I only end up with 1 line per item within each plant.
I need to end up with this:

"PLANT 5 - LINE 1","37450","16"
"PLANT 5 - LINE 1","37896","8"
"PLANT 5 - LINE 1","38280","36"
"PLANT 5 - LINE 2","37450","36"
"PLANT 5 - LINE 2","38721","16"
"PLANT 5 - LINE 2","38722","8"
"PLANT 5 - LINE 4","38668","4"
"PLANT 5 - LINE 4","37450","16"

Not sure where to start on this, can someone offer suggestions?

Or you could drop your data in a DataGridView and use some of the many properties and methods of this rather big, but very usefull object. See this example.

Here's what I've done so far, and it appears to be sorting correctly:

            DataTable dtResult;

            using (GenericParsing.GenericParserAdapter p = new GenericParsing.GenericParserAdapter(@"s:\hp\haylin.csv"))
            {
                dtResult = p.GetDataTable();
            }

            DataView dv = dtResult.DefaultView;
            dv.Sort = "Column6, Column4 ASC";
            DataTable dt2 = dv.ToTable("Table2");

Can you offer some suggestions on how to do the next step, which is to get subtotals per item?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.