Convert rows of beautiful table to listHow do I check if a list is empty?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How do you split a list into evenly sized chunks?Converting string into datetimeHow do I remove an element from a list by index in Python?How to make a flat list out of list of lists“Least Astonishment” and the Mutable Default ArgumentHow do I list all files of a directory?Get list from pandas DataFrame column headers
Why Isn’t SQL More Refactorable?
Building a list of products from the elements in another list
What was the design of the Macintosh II's MMU replacement?
What was the first instance of a "planet eater" in sci-fi?
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Why is B♯ higher than C♭ in 31-ET?
Manager is threatening to grade me poorly if I don't complete the project
Can a nothic's Weird Insight action discover secrets about a player character that the character doesn't know about themselves?
Will 700 more planes a day fly because of the Heathrow expansion?
Verb "geeitet" in an old scientific text
How can I support myself financially as a 17 year old with a loan?
Has a commercial or military jet bi-plane ever been manufactured?
I'm in your subnets, golfing your code
Using column size much larger than necessary
Upside-Down Pyramid Addition...REVERSED!
How I can I roll a number of non-digital dice to get a random number between 1 and 150?
How did Shepard's and Grissom's speeds compare with orbital velocity?
How to display a value with zenity?
Why did the Apollo 13 crew extend the LM landing gear?
How can I close a gap between my fence and my neighbor's that's on his side of the property line?
How wide is a neg symbol, how to get the width for alignment?
Why wasn't the Night King naked in S08E03?
Set collection doesn't always enforce uniqueness with the Date datatype? Does the following example seem correct?
Why are prions in animal diets not destroyed by the digestive system?
Convert rows of beautiful table to list
How do I check if a list is empty?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How do you split a list into evenly sized chunks?Converting string into datetimeHow do I remove an element from a list by index in Python?How to make a flat list out of list of lists“Least Astonishment” and the Mutable Default ArgumentHow do I list all files of a directory?Get list from pandas DataFrame column headers
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I would like to convert the rows of beautifultable to elements of a list while excluding the header e.g:
[['A',2,4], ['B',2,5], ['C',2,1]]
python python-beautifultable
add a comment |
I would like to convert the rows of beautifultable to elements of a list while excluding the header e.g:
[['A',2,4], ['B',2,5], ['C',2,1]]
python python-beautifultable
add a comment |
I would like to convert the rows of beautifultable to elements of a list while excluding the header e.g:
[['A',2,4], ['B',2,5], ['C',2,1]]
python python-beautifultable
I would like to convert the rows of beautifultable to elements of a list while excluding the header e.g:
[['A',2,4], ['B',2,5], ['C',2,1]]
python python-beautifultable
python python-beautifultable
edited Mar 26 at 18:36
Taiwo O. Adetiloye
asked Mar 22 at 22:14
Taiwo O. AdetiloyeTaiwo O. Adetiloye
467822
467822
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Just call
list(map(list, table))
the full code:
from beautifultable import BeautifulTable
table = BeautifulTable()
table.column_headers = ["c1", "c2", "c3"]
table.append_row(['A', 2, 4])
table.append_row(['B', 2, 5])
table.append_row(['C', 2, 6])
print(table)
# it will print
# +----+----+----+
# | c1 | c2 | c3 |
# +----+----+----+
# | A | 2 | 4 |
# +----+----+----+
# | B | 2 | 5 |
# +----+----+----+
# | C | 2 | 6 |
# +----+----+----+
li = list(map(list, table))
print(li)
# it will print
# [['A', 2, 4], ['B', 2, 5], ['C', 2, 6]]
add a comment |
Beautifultable would give the following result if you try to get the rows:
list([r for r in table])
=> [RowData<'A',2,4>, RowData<'B',2,5>, RowData<'C',2,1>]
To convert it to the form: [['A',2,4], ['B',2,5], ['C',2,1]]
Use:
list([list(r) for r in table])
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308464%2fconvert-rows-of-beautiful-table-to-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just call
list(map(list, table))
the full code:
from beautifultable import BeautifulTable
table = BeautifulTable()
table.column_headers = ["c1", "c2", "c3"]
table.append_row(['A', 2, 4])
table.append_row(['B', 2, 5])
table.append_row(['C', 2, 6])
print(table)
# it will print
# +----+----+----+
# | c1 | c2 | c3 |
# +----+----+----+
# | A | 2 | 4 |
# +----+----+----+
# | B | 2 | 5 |
# +----+----+----+
# | C | 2 | 6 |
# +----+----+----+
li = list(map(list, table))
print(li)
# it will print
# [['A', 2, 4], ['B', 2, 5], ['C', 2, 6]]
add a comment |
Just call
list(map(list, table))
the full code:
from beautifultable import BeautifulTable
table = BeautifulTable()
table.column_headers = ["c1", "c2", "c3"]
table.append_row(['A', 2, 4])
table.append_row(['B', 2, 5])
table.append_row(['C', 2, 6])
print(table)
# it will print
# +----+----+----+
# | c1 | c2 | c3 |
# +----+----+----+
# | A | 2 | 4 |
# +----+----+----+
# | B | 2 | 5 |
# +----+----+----+
# | C | 2 | 6 |
# +----+----+----+
li = list(map(list, table))
print(li)
# it will print
# [['A', 2, 4], ['B', 2, 5], ['C', 2, 6]]
add a comment |
Just call
list(map(list, table))
the full code:
from beautifultable import BeautifulTable
table = BeautifulTable()
table.column_headers = ["c1", "c2", "c3"]
table.append_row(['A', 2, 4])
table.append_row(['B', 2, 5])
table.append_row(['C', 2, 6])
print(table)
# it will print
# +----+----+----+
# | c1 | c2 | c3 |
# +----+----+----+
# | A | 2 | 4 |
# +----+----+----+
# | B | 2 | 5 |
# +----+----+----+
# | C | 2 | 6 |
# +----+----+----+
li = list(map(list, table))
print(li)
# it will print
# [['A', 2, 4], ['B', 2, 5], ['C', 2, 6]]
Just call
list(map(list, table))
the full code:
from beautifultable import BeautifulTable
table = BeautifulTable()
table.column_headers = ["c1", "c2", "c3"]
table.append_row(['A', 2, 4])
table.append_row(['B', 2, 5])
table.append_row(['C', 2, 6])
print(table)
# it will print
# +----+----+----+
# | c1 | c2 | c3 |
# +----+----+----+
# | A | 2 | 4 |
# +----+----+----+
# | B | 2 | 5 |
# +----+----+----+
# | C | 2 | 6 |
# +----+----+----+
li = list(map(list, table))
print(li)
# it will print
# [['A', 2, 4], ['B', 2, 5], ['C', 2, 6]]
answered Mar 22 at 22:44
Yao YuanYao Yuan
465
465
add a comment |
add a comment |
Beautifultable would give the following result if you try to get the rows:
list([r for r in table])
=> [RowData<'A',2,4>, RowData<'B',2,5>, RowData<'C',2,1>]
To convert it to the form: [['A',2,4], ['B',2,5], ['C',2,1]]
Use:
list([list(r) for r in table])
add a comment |
Beautifultable would give the following result if you try to get the rows:
list([r for r in table])
=> [RowData<'A',2,4>, RowData<'B',2,5>, RowData<'C',2,1>]
To convert it to the form: [['A',2,4], ['B',2,5], ['C',2,1]]
Use:
list([list(r) for r in table])
add a comment |
Beautifultable would give the following result if you try to get the rows:
list([r for r in table])
=> [RowData<'A',2,4>, RowData<'B',2,5>, RowData<'C',2,1>]
To convert it to the form: [['A',2,4], ['B',2,5], ['C',2,1]]
Use:
list([list(r) for r in table])
Beautifultable would give the following result if you try to get the rows:
list([r for r in table])
=> [RowData<'A',2,4>, RowData<'B',2,5>, RowData<'C',2,1>]
To convert it to the form: [['A',2,4], ['B',2,5], ['C',2,1]]
Use:
list([list(r) for r in table])
edited Mar 26 at 18:35
answered Mar 22 at 22:33
Taiwo O. AdetiloyeTaiwo O. Adetiloye
467822
467822
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308464%2fconvert-rows-of-beautiful-table-to-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown