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

  • SEARCH
  • Home
  • 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 9211309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:15:55+00:00 2026-06-18T01:15:55+00:00

I’m currently doing a project where I collect a lot of information about processes

  • 0

I’m currently doing a project where I collect a lot of information about processes and CPU usage, battery usage etc in to tables.

For example, “Log table” contains the columns ‘Process’, ‘Pid’, ‘Battery’ and another table, “CPU Table”, contains for example ‘Process’, ‘CPU Time’, ‘CPU Usage’. The program writes to all these tables at the same time so each reading has it’s own line across all the tables.

I have created a program that takes all this information and creates a separate CSV file for all the processes. Within these files, I want to have all the information from all four tables about that particular process.

The problem I am having is that for some reason, when I attempt to bring the information in, one of the tables duplicates it’s records for every record from the other table.

problem

As you can see, the information from “Log table” writes out correctly, but the information from “CPU table” (the 7 furthest right columns) repeat the first record for every entry of “Log”, and then does the same for the second, and for every record of Log.

Procs[i] contains all unique process names.

Currently, the sql statement I am using is and the basic code surrounding is:

String query = "SELECT * FROM log, cpuinfo WHERE log.Process = " + "'" + procs[i] + "'" + " AND cpuinfo.Process = " + "'" + procs[i] + "'";
                System.out.println(query);
                rs = sment.executeQuery(query);

                writer = new CSVWriter(new FileWriter(procs[i] + ".csv"), ',');
                //writer = new CSVWriter(procs[i] + ".csv");
                //System.out.println("Writing.....");



                //rs.beforeFirst();

                writer.writeAll(rs, true);
                //writer.

                writer.flush();

Can anyone see why the program is doing this and writing the CSV in this way? Any help would be hugely appreciated, been stuck on this program for weeks now to no avail and Google isn’t helping!

Thanks.

If you need any information or the code to look at please do ask!

  • 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-18T01:15:57+00:00Added an answer on June 18, 2026 at 1:15 am

    You are implicitly performing an inner join of the two tables log and cpuinfo here, and you need to decide how to properly associate one record from log with one record from cpuinfo. Your query as written effectively creates a result record for every record from log joined up with every record from cpuinfo, and then your WHERE clause is restricting that result set to only those records where the processes match up.

    This doesn’t seem to be what you want; it seems to me that you probably want to associate records where the process matches up AND the timestamps match as well. Naively this might look like the following:

    SELECT * FROM log, cpuinfo WHERE log.Process = ?  AND cpuinfo.Process = ? 
      AND log.Timestamp = cpuinfo.Timestamp
    

    However, I believe your solution is actually a bit more complicated than naively comparing timestamps. It looks like there probably is a way to match timestamps from one table to another, but it appears the associated timestamps might not be identical. For instance, the earliest timestamp in log looks like 26:04.2 as opposed to 26:04.3 in cpuinfo. You would need to decide, based upon application logic, the way in which it makes sense to associated two timestamps with one another. This would then affect your WHERE clause accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
i got an object with contents of html markup in it, for example: string
I have a view passing on information from a database: def serve_article(request, id): served_article

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.