Python Forum
Organizing the output of 2 for loops
Thread Rating:
  • 2 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Organizing the output of 2 for loops
#1
I have 2 for loops that fetch data from 2 different data sources, one for loop prints an output of 15 rows and 6 columns and another for loop prints an output of 18 rows and 6 columns like below , sample output

For loop 1 output:
[Image: for1.png]
For loop 2 output:
[Image: for_2.png]

i want them to be combined and organised in such a way that they are sorted based on column 6 with the column1 of for loop 1's output is fixed as follows,
[Image: expected.png]

How can i organize the output from these 2 for loops to create this output. i am not sure where to start, however i tried creating individual lists by appending the output that i get from the for loop and it throws an error that it can accept only one argument as below

 io = []
    for obj in hearts:            
        rawvalue = obj.raw - readvalue
        if rawvalue < 0:
            rawvalue = rawvalue + 440
        else:
            rawvalue
        obj = str(obj)
        obj = ((obj.strip('<').split(" ")[0]))
        io.append(obj, viewdata(rawvalue)[0][3],viewdata(rawvalue)[0][0], viewdata(rawvalue)[0][1], viewdata(rawvalue)[0][2],rawvalue)
Quote:TypeError: append() takes exactly one argument (6 given)

What should be done to make this work
Reply


Messages In This Thread
Organizing the output of 2 for loops - by pythoneer - May-19-2018, 04:53 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020