VB.Net Filter DataTable By Time Column Every 10 Seconds [closed]











up vote
-1
down vote

favorite












I have a DataTable that I need to filter down by the Time column so that it keeps rows only every 10 seconds.



I can get it to work by looping through each row but I was hoping there was an easier way using LINQ and the Select call on the DataTable.



Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column.



Most of the time that DateTime column will be once per second but it can vary.



What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row.



Example:
Row 1 - 9:00am,
Row 2 - 9:01am,
Row 3 - 9:02am,
....
Row 11 - 9:10am



I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match










share|improve this question















closed as too broad by Gert Arnold, Blackwood, NetMage, EJoshuaS, Makyen Nov 21 at 21:49


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • What do you mean by "filter"? What do you mean by "keep"?
    – NetMage
    Nov 21 at 21:14










  • Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
    – BBousman
    Nov 26 at 14:56












  • You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
    – NetMage
    Nov 26 at 18:34












  • Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
    – BBousman
    Nov 26 at 22:13










  • It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
    – NetMage
    Nov 26 at 22:37

















up vote
-1
down vote

favorite












I have a DataTable that I need to filter down by the Time column so that it keeps rows only every 10 seconds.



I can get it to work by looping through each row but I was hoping there was an easier way using LINQ and the Select call on the DataTable.



Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column.



Most of the time that DateTime column will be once per second but it can vary.



What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row.



Example:
Row 1 - 9:00am,
Row 2 - 9:01am,
Row 3 - 9:02am,
....
Row 11 - 9:10am



I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match










share|improve this question















closed as too broad by Gert Arnold, Blackwood, NetMage, EJoshuaS, Makyen Nov 21 at 21:49


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.















  • What do you mean by "filter"? What do you mean by "keep"?
    – NetMage
    Nov 21 at 21:14










  • Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
    – BBousman
    Nov 26 at 14:56












  • You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
    – NetMage
    Nov 26 at 18:34












  • Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
    – BBousman
    Nov 26 at 22:13










  • It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
    – NetMage
    Nov 26 at 22:37















up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a DataTable that I need to filter down by the Time column so that it keeps rows only every 10 seconds.



I can get it to work by looping through each row but I was hoping there was an easier way using LINQ and the Select call on the DataTable.



Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column.



Most of the time that DateTime column will be once per second but it can vary.



What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row.



Example:
Row 1 - 9:00am,
Row 2 - 9:01am,
Row 3 - 9:02am,
....
Row 11 - 9:10am



I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match










share|improve this question















I have a DataTable that I need to filter down by the Time column so that it keeps rows only every 10 seconds.



I can get it to work by looping through each row but I was hoping there was an easier way using LINQ and the Select call on the DataTable.



Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column.



Most of the time that DateTime column will be once per second but it can vary.



What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row.



Example:
Row 1 - 9:00am,
Row 2 - 9:01am,
Row 3 - 9:02am,
....
Row 11 - 9:10am



I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match







vb.net linq datatable






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 at 22:11

























asked Nov 21 at 20:17









BBousman

54




54




closed as too broad by Gert Arnold, Blackwood, NetMage, EJoshuaS, Makyen Nov 21 at 21:49


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as too broad by Gert Arnold, Blackwood, NetMage, EJoshuaS, Makyen Nov 21 at 21:49


Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • What do you mean by "filter"? What do you mean by "keep"?
    – NetMage
    Nov 21 at 21:14










  • Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
    – BBousman
    Nov 26 at 14:56












  • You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
    – NetMage
    Nov 26 at 18:34












  • Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
    – BBousman
    Nov 26 at 22:13










  • It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
    – NetMage
    Nov 26 at 22:37




















  • What do you mean by "filter"? What do you mean by "keep"?
    – NetMage
    Nov 21 at 21:14










  • Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
    – BBousman
    Nov 26 at 14:56












  • You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
    – NetMage
    Nov 26 at 18:34












  • Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
    – BBousman
    Nov 26 at 22:13










  • It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
    – NetMage
    Nov 26 at 22:37


















What do you mean by "filter"? What do you mean by "keep"?
– NetMage
Nov 21 at 21:14




What do you mean by "filter"? What do you mean by "keep"?
– NetMage
Nov 21 at 21:14












Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
– BBousman
Nov 26 at 14:56






Say you have a DataTable with 100 rows of data with various columns but most importantly a "DateTime" column. Most of the time that DateTime column will be once per second but it can vary. What I need to do is remove all rows except for the ones that are every 10 seconds after the time of the first row. Example: Row 1 - 9:00am, Row 2 - 9:01am, Row 3 - 9:02am, .... Row 11 - 9:10am I would want to keep Rows 1 and 11 and remove the rest. Right now what I'm doing is taking the start time, adding 10 seconds and finding the closest match
– BBousman
Nov 26 at 14:56














You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
– NetMage
Nov 26 at 18:34






You need to update your question to be clear - add the additional information by editing your question. Also, what does "every 10 seconds" mean when your times aren't consistent?
– NetMage
Nov 26 at 18:34














Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
– BBousman
Nov 26 at 22:13




Updated question. The recording time will be consistent throughout (i.e. once per second) but the rate at which it records could be anything really (i.e. once every half second/twice per second, once every 2 seconds, once every 3 seconds, etc.).
– BBousman
Nov 26 at 22:13












It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
– NetMage
Nov 26 at 22:37






It would help if your example went beyond 11 seconds, e.g. do you want every 10th row after the first? That would be easy... If the rate is every 3 seconds, the first kept row is 9:00:00am, the next is 9:00:12am? What about after that? Is it 9:00:21am or 9:00:24am?
– NetMage
Nov 26 at 22:37














1 Answer
1






active

oldest

votes

















up vote
-1
down vote













Your question is not very clear, but from what i understood try

var a = DateTime.Now;
var data= from d in datatable
where d.log_time.Date == a.Date
select d.done;





share|improve this answer





















  • It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
    – Gert Arnold
    Nov 21 at 21:38










  • See my comment above
    – BBousman
    Nov 26 at 15:00


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
-1
down vote













Your question is not very clear, but from what i understood try

var a = DateTime.Now;
var data= from d in datatable
where d.log_time.Date == a.Date
select d.done;





share|improve this answer





















  • It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
    – Gert Arnold
    Nov 21 at 21:38










  • See my comment above
    – BBousman
    Nov 26 at 15:00















up vote
-1
down vote













Your question is not very clear, but from what i understood try

var a = DateTime.Now;
var data= from d in datatable
where d.log_time.Date == a.Date
select d.done;





share|improve this answer





















  • It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
    – Gert Arnold
    Nov 21 at 21:38










  • See my comment above
    – BBousman
    Nov 26 at 15:00













up vote
-1
down vote










up vote
-1
down vote









Your question is not very clear, but from what i understood try

var a = DateTime.Now;
var data= from d in datatable
where d.log_time.Date == a.Date
select d.done;





share|improve this answer












Your question is not very clear, but from what i understood try

var a = DateTime.Now;
var data= from d in datatable
where d.log_time.Date == a.Date
select d.done;






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 21:21









sandeep

92




92












  • It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
    – Gert Arnold
    Nov 21 at 21:38










  • See my comment above
    – BBousman
    Nov 26 at 15:00


















  • It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
    – Gert Arnold
    Nov 21 at 21:38










  • See my comment above
    – BBousman
    Nov 26 at 15:00
















It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
– Gert Arnold
Nov 21 at 21:38




It's usually a frustrating business to answer unclear questions. Also, suggestions to try something don't really qualify as answers. Please wait until you can comment so you can ask for clarification before answering.
– Gert Arnold
Nov 21 at 21:38












See my comment above
– BBousman
Nov 26 at 15:00




See my comment above
– BBousman
Nov 26 at 15:00



Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks