473,441 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

group by in dataview

Hello,
I have a dataview that contains about 300k records with 3 cols (read
in from a directory). I need to get the count of rows by col1 and col2
(grouping by col1 and col2). What would be the best way to do it?
Currently, I am sorting them and reading each row and comparing
current row's col1 and col2 with previous row's col1 and col2 and
keeping the total in an arraylist. But this is very slow; I am pretty
new to C#, any help is appreciated.

Thanks.
Nov 15 '05 #1
4 24982
Hello,

Unfortunately, you have said nothing about the source of the data. If this
is some kind of database, it would be much better to perform the grouping by
using the database means, such as 'GROUP BY' SQL clause.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"luke" <lu*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
Hello,
I have a dataview that contains about 300k records with 3 cols (read
in from a directory). I need to get the count of rows by col1 and col2
(grouping by col1 and col2). What would be the best way to do it?
Currently, I am sorting them and reading each row and comparing
current row's col1 and col2 with previous row's col1 and col2 and
keeping the total in an arraylist. But this is very slow; I am pretty
new to C#, any help is appreciated.

Thanks.


Nov 15 '05 #2
Hi luke,

AFAIK this is the only way.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"luke" <lu*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
Hello,
I have a dataview that contains about 300k records with 3 cols (read
in from a directory). I need to get the count of rows by col1 and col2
(grouping by col1 and col2). What would be the best way to do it?
Currently, I am sorting them and reading each row and comparing
current row's col1 and col2 with previous row's col1 and col2 and
keeping the total in an arraylist. But this is very slow; I am pretty
new to C#, any help is appreciated.

Thanks.

Nov 15 '05 #3
I am rading in filenames from a folder and filling a table out of
their parsed name. Eg, abcde.txt would be put into table where 'a' is
a column, so as b,c,d and e. Now, I need to know how many files that
match columna and columnc exist and get their total. I hope I am being
clear ...

Thanks.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<uo**************@TK2MSFTNGP09.phx.gbl>...
Hello,

Unfortunately, you have said nothing about the source of the data. If this
is some kind of database, it would be much better to perform the grouping by
using the database means, such as 'GROUP BY' SQL clause.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"luke" <lu*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
Hello,
I have a dataview that contains about 300k records with 3 cols (read
in from a directory). I need to get the count of rows by col1 and col2
(grouping by col1 and col2). What would be the best way to do it?
Currently, I am sorting them and reading each row and comparing
current row's col1 and col2 with previous row's col1 and col2 and
keeping the total in an arraylist. But this is very slow; I am pretty
new to C#, any help is appreciated.

Thanks.

Nov 15 '05 #4
Luke,
I hope I am being
clear ... Not really, are you saying you are parsing each position of the name into a
distinct DataTable column? You do realize that file names can be upto 256
characters so you would need 256 columns?

I would consider defining "parent" tables for your grouping (one for each
grouping), then as I am adding rows to the first DataTable, update the
"parent" datatable with new values. I would also define relationships
between these datatables, so I could use the DataRow.GetChildRows method...

DataTables:
G1 : c1
G2 : c1, c2
G3 : c1, c2, c3

D : c1, c2, c3, c4

c1, c2, c3 & c4 are columns, while G1, G2, & G3 are my grouping tables, & D
is your existing DataTable.

Hope this helps
Jay

"luke" <lu*****@yahoo.com> wrote in message
news:87*************************@posting.google.co m... I am rading in filenames from a folder and filling a table out of
their parsed name. Eg, abcde.txt would be put into table where 'a' is
a column, so as b,c,d and e. Now, I need to know how many files that
match columna and columnc exist and get their total. I hope I am being
clear ...

Thanks.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote

in message news:<uo**************@TK2MSFTNGP09.phx.gbl>...
Hello,

Unfortunately, you have said nothing about the source of the data. If this is some kind of database, it would be much better to perform the grouping by using the database means, such as 'GROUP BY' SQL clause.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"luke" <lu*****@yahoo.com> wrote in message
news:87**************************@posting.google.c om...
Hello,
I have a dataview that contains about 300k records with 3 cols (read
in from a directory). I need to get the count of rows by col1 and col2
(grouping by col1 and col2). What would be the best way to do it?
Currently, I am sorting them and reading each row and comparing
current row's col1 and col2 with previous row's col1 and col2 and
keeping the total in an arraylist. But this is very slow; I am pretty
new to C#, any help is appreciated.

Thanks.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RPI_alum | last post by:
I've been experiencing some frustrating behavior that I believe may be a MS bug in the Framework. Has anyone else experienced this, know a better way to resolve it, or if it is an actual MS bug ...
5
by: Amadelle | last post by:
Hi All and thanks in advance, I was wondering what is the best way of grouping data in a dataset. Like using a "Group By" clause in Sql statements. I was thinking of using XML but I don't even...
2
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
1
by: Brent Mondoux | last post by:
Hey everyone, I'm trying to find the best non-spaghetti code way to do the equivalent of a ColdFusion CFQUERY GROUP command so that I can display a FAQ with categories as follows: -- Example:...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
5
by: enceladus311 | last post by:
I'm trying to find a way to keep from having to fill a DataView after every PostBack to a page. Basically, the design is that I have a DataView that I fill, which I then set as the DataSource to a...
2
by: frostbb | last post by:
The following code works great in C# Net 1.0 & Net 1.1 apps ... doesn't work for Net 2.0 apps. Cannot get pDg.IsSelected(i) to toggle to 'true' for 'highlighted' rows in a DataGrid control. ...
0
by: Pravin Pujari | last post by:
Hi All, I am using .net framework 1.1 and c#. I have one problem regarding dataview. I have one dataview to which sorting may be applied or may not be applied. I have one UI component where I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.