Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add add_rows to add several rows at once #75

Merged
merged 1 commit into from
Nov 1, 2020
Merged

Add add_rows to add several rows at once #75

merged 1 commit into from
Nov 1, 2020

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Oct 28, 2020

When you have a list of rows, you can add them in one go with add_rows:

from prettytable import PrettyTable

x = PrettyTable()
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
x.add_rows(
    [
        ["Adelaide", 1295, 1158259, 600.5],
        ["Brisbane", 5905, 1857594, 1146.4],
        ["Darwin", 112, 120900, 1714.7],
        ["Hobart", 1357, 205556, 619.5],
        ["Sydney", 2058, 4336374, 1214.8],
        ["Melbourne", 1566, 3806092, 646.9],
        ["Perth", 5386, 1554769, 869.4],
    ]
)

print(x)
+-----------+------+------------+-----------------+
| City name | Area | Population | Annual Rainfall |
+-----------+------+------------+-----------------+
|  Adelaide | 1295 |  1158259   |      600.5      |
|  Brisbane | 5905 |  1857594   |      1146.4     |
|   Darwin  | 112  |   120900   |      1714.7     |
|   Hobart  | 1357 |   205556   |      619.5      |
|   Sydney  | 2058 |  4336374   |      1214.8     |
| Melbourne | 1566 |  3806092   |      646.9      |
|   Perth   | 5386 |  1554769   |      869.4      |
+-----------+------+------------+-----------------+

@hugovk hugovk added enhancement New feature or request changelog: Added For new features labels Oct 28, 2020
@codecov
Copy link

codecov bot commented Oct 28, 2020

Codecov Report

Merging #75 into master will increase coverage by 0.09%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #75      +/-   ##
==========================================
+ Coverage   87.22%   87.31%   +0.09%     
==========================================
  Files           3        3              
  Lines        1487     1498      +11     
==========================================
+ Hits         1297     1308      +11     
  Misses        190      190              
Flag Coverage Δ
#GHA_Ubuntu 87.31% <100.00%> (+0.09%) ⬆️
#GHA_Windows 87.31% <100.00%> (+0.09%) ⬆️
#GHA_macOS 87.31% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/prettytable/prettytable.py 82.25% <100.00%> (+0.04%) ⬆️
tests/test_prettytable.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7e44b1...860269c. Read the comment docs.

@hugovk hugovk merged commit 8b415f9 into jazzband:master Nov 1, 2020
@hugovk hugovk deleted the add-add_rows branch November 1, 2020 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Added For new features enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant