Python Forum
Make a table from a json output
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make a table from a json output
#7
(Dec-30-2018, 08:43 PM)stullis Wrote: What error are you getting?

As for an explanation, the function accepts a list of sub-lists and transforms it. The transformation process (in the loop) takes the data in each sub-list for a specified index and aggregates them into a single list. Like so:

[[1,2,3],[1,2,3]] => [[1,1],[2,2],[3,3]]

This saves a lot of effort to change your data set into rows for the table.

Since i got that error from your code i tried a bit my self, and got below. But only gives me the first line, and since your code is working for me now, i stick to that :)

entries = len(date)

t = PrettyTable(title)

count = 1
while count <= entries:
    t.add_row(
        [date[0], day[0], week[0], season[0], team[0], oteam[0], site[0], points[0], opoints[0], line[0], total[0]])
    if count == entries:
        break
    count +=1
Just tried running your code again. And it worked perfect.. Have no idea what i did earlier today. :D
It looks great. Does exactly what i needed :)

How do i add a header column? Like sum.. Where i can add the points and opoints

Thanks for input stullis. Taking it all in and learning for future stuff :)
Reply


Messages In This Thread
Make a table from a json output - by carstenlp - Dec-29-2018, 09:10 PM
RE: Make a table from a json output - by Unisoftdev - Dec-29-2018, 10:17 PM
RE: Make a table from a json output - by carstenlp - Dec-29-2018, 11:32 PM
RE: Make a table from a json output - by stullis - Dec-30-2018, 12:36 AM
RE: Make a table from a json output - by carstenlp - Dec-30-2018, 05:21 PM
RE: Make a table from a json output - by stullis - Dec-30-2018, 08:43 PM
RE: Make a table from a json output - by carstenlp - Dec-30-2018, 09:35 PM
RE: Make a table from a json output - by snippsat - Dec-30-2018, 11:04 PM
RE: Make a table from a json output - by carstenlp - Jan-01-2019, 08:30 PM
RE: Make a table from a json output - by snippsat - Jan-01-2019, 09:42 PM
RE: Make a table from a json output - by carstenlp - Jan-04-2019, 08:58 PM
RE: Make a table from a json output - by snippsat - Jan-04-2019, 10:37 PM
RE: Make a table from a json output - by carstenlp - Jan-05-2019, 09:52 PM
RE: Make a table from a json output - by carstenlp - Jan-12-2019, 09:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  write json into a table herobpv 4 1,514 Jan-22-2023, 04:36 AM
Last Post: herobpv
  Convert Json to table format python_student 2 5,582 Sep-28-2022, 12:48 PM
Last Post: python_student
  geojson to json --missing multiple row output yoshi 9 2,808 Mar-06-2022, 08:34 PM
Last Post: snippsat
  Python script to summarize excel tables, then output a composite table? i'm a total n surfer349 1 2,364 Feb-05-2021, 04:37 PM
Last Post: nilamo
  sports Stats > table output loop problems paulfearn100 3 2,533 Jul-22-2020, 03:21 AM
Last Post: c_rutherford
  Save output into a Excel Sheet with Format Table skaailet 1 2,514 Apr-17-2020, 11:56 PM
Last Post: thirteendec
  json.dumps list output qurr 12 5,281 Apr-08-2020, 10:13 PM
Last Post: micseydel
  json.dumps output error in python3 prayuktibid 2 2,676 Jan-21-2020, 06:41 AM
Last Post: prayuktibid
  Output to a json file problem Netcode 3 3,749 Nov-22-2019, 01:44 AM
Last Post: Skaperen
  Problem Table Output Phil 4 2,651 May-19-2019, 12:17 PM
Last Post: Phil

Forum Jump:

User Panel Messages

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