Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9272145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:47:58+00:00 2026-06-18T15:47:58+00:00

Good morning, I’ve got two lists that I need to merge together and create

  • 0

Good morning, I’ve got two lists that I need to merge together and create a data table from, I’ve got the following block of code:

private static DataTable GetDataTable(IList<DataValue> listOneDataValues,
                                            IList<DataValue> listTwoDataValues)
      {
         var dataTable = new DataTable();
         dataTable.Columns.Add("ColumnFromListOne");
         dataTable.Columns.Add("ColumnFromListTwo");
         dataTable.Columns.Add("TimeStamp");

         //Group the lists together
         var query = (from listOne in listOneDataValues
                      from listTwo in listTwoDataValues
                      let columnFromListOne= listOne.DoubleValue
                      let columnFromListTwo= listTwo.DoubleValue
                      let timestamp = listOne.TimeStamp
                      where listOne.TimeStamp == listTwo.TimeStamp
                      select new {ColumnFromListTwo = columnFromListOne, ColumnFromListOne = columnFromListTwo, Timestamp = timestamp});


         foreach(var q in query)
            dataTable.Rows.Add(q.ColumnFromListOne, q.ColumnFromListTwo, q.TimeStamp);

         return dataTable;
      }

The problem is the two lists contain timestamps that are off by a matter of seconds, and they don’t align at all, so my end result ends up with one or zero records in the datatable, even though each list contains 200+ records. I’m pretty bad with LINQ and would appreciate a point in the right direction. I guess I need to interpolate the timestamps before grouping, but I would like to know the best practice pattern for doing something like this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:47:59+00:00Added an answer on June 18, 2026 at 3:47 pm

    You need to decide what an appropriate threshold is for calling two time stamps “equal” – knowing that too large a threshold will give you false positives and too small a threshold will prevent some records from joining.

    From there just change your query to

         int threshold = 5;
         //Group the lists together
         var query = (from listOne in listOneDataValues
                      from listTwo in listTwoDataValues
                      where Math.Abs(
                                        (listOne.TimeStamp - listTwo.TimeStamp)
                                         .TotalSeconds
                                    ) <= threshold
                      select new {
                                     ColumnFromListTwo = listTwo.DoubleValue,
                                     ColumnFromListOne = listOne.DoubleValue, 
                                     Timestamp = listOne.TimeStamp
                                 });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good Morning. I've got the following definition (this program was created by the guy
Good Morning, I've written the following stored procedure that searches for records that have
Good Morning All, I have an Objective C question that is coming from JavaScript.
Good morning, I am retrieving a stream of bytes from a serial device that
good morning. We need to copy tables from Access to SQL. Thing is the
Good morning, I'm reading two numbers from a FITS file (representing the integer and
Good morning, I am currently developing a java web application that exposes a web
Good Morning. I have two tables, and one references the other. When I insert
Good morning gang. I have a jQuery Datepicker object that is prepoulated using a
Good morning ! What is the best way to remove duplicate records from grid

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.