Skip to content

Commit

Permalink
release v1.0.0
Browse files Browse the repository at this point in the history
wrote readme
  • Loading branch information
Bash Elliott authored Apr 10, 2022
2 parents d9b1b13 + dc7d9bb commit 0bb91f2
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 25 deletions.
92 changes: 80 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,83 @@
<br><br>
</div>

# Todo
- [x] [Create base table.](https://github.com/raccter/bashtable/issues/1)
- [x] [Implement multiple rows.](https://github.com/raccter/bashtable/issues/2)
- [x] [Implement multiple columns.](https://github.com/raccter/bashtable/issues/3)
- [x] [Implement column titles.](https://github.com/raccter/bashtable/issues/5)
- [x] [Implement dynamic resizing of columns depending on size of data within each column.](https://github.com/raccter/bashtable/issues/6)
- [ ] [Write readme](https://github.com/raccter/bashtable/issues/10)
- [ ] Try not to die in the process.

# Future Features
- [ ] Custom themes.
- [ ] Customizable colors of elements in tables.
Bashtable is a tables package for Python that provides a simple and easy to use system for creating simplistic and professional looking tables to use in your Python programs.

Bashtable is inspired by [Kyostenas' prettyTables](https://github.com/Kyostenas/prettyTables) and is intended as a simpler way to display data in the Python console.

# Table of Contents
- [Installation](#installation)
* [Using pip](#using-pip)
* [Using setup.py](#using-setuppy)
- [Usage](#usage)
* [Basic bashtable](#basic-bashtable)
* [Adding column titles](#adding-column-titles)
- [Support and Contributions](#support-and-contributions)

# Installation
## Using pip
Run `python -m pip install bashtable` in the context of your choice, and Bashtable will be installed into your Python installation's site-packages.
## Using setup.py
Download the latest release's source code and run `python setup.py install` in the root directory.

# Usage
## Basic bashtable

**Input**
```python
from bashtable import bashtable

table = bashtable()
table.setData(0, "Bash", "Elliott", "17")
table.setData(1, "Jane", "Doe", "21")
table.setData(2, "John", "Doe", "21")
table.draw()
```

**Output**
```
╔══════╦═════════╦════╗
║ ║ ║ ║
╠══════╬═════════╬════╣
│ Bash │ Elliott │ 17 │
├──────┼─────────┼────┤
│ Jane │ Doe │ 21 │
├──────┼─────────┼────┤
│ John │ Doe │ 21 │
╚──────┴─────────┴────╝
```

## Adding column titles

**Input**
```python
from bashtable import bashtable

table = bashtable()
table.setColumnTitle(0, "First Name")
table.setColumnTitle(1, "Last Name")
table.setColumnTitle(2, "Age")

table.setData(0, "Bash", "Elliott", "17")
table.setData(1, "Jane", "Doe", "21")
table.setData(2, "John", "Doe", "21")
table.draw()
```

**Output**
```
╔════════════╦═══════════╦═════╗
║ First Name ║ Last Name ║ Age ║
╠════════════╬═══════════╬═════╣
│ Bash │ Elliott │ 17 │
├────────────┼───────────┼─────┤
│ Jane │ Doe │ 21 │
├────────────┼───────────┼─────┤
│ John │ Doe │ 21 │
╚────────────┴───────────┴─────╝
```

# Support and Contributions
If you have any suggestions for Bashbox or want to fork Bashbox to improve upon it or add any features, feel free to do so and even make a pull request! I appreciate each and every contribution made.

If you've found a bug, please make an issue so I can work towards fixing it. I am also reachable by email at spicethings9@gmail.com.
11 changes: 11 additions & 0 deletions examples/adding_titles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from bashtable import bashtable

table = bashtable()
table.setColumnTitle(0, "First Name")
table.setColumnTitle(1, "Last Name")
table.setColumnTitle(2, "Age")

table.setData(0, "Bash", "Elliott", "17")
table.setData(1, "Jane", "Doe", "21")
table.setData(2, "John", "Doe", "21")
table.draw()
7 changes: 7 additions & 0 deletions examples/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from bashtable import bashtable

table = bashtable()
table.setData(0, "Bash", "Elliott", "17")
table.setData(1, "Jane", "Doe", "21")
table.setData(2, "John", "Doe", "21")
table.draw()
Empty file removed examples/placeholder
Empty file.
19 changes: 6 additions & 13 deletions src/bashtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def draw(self):
# Print title row.
titleRow = EdgeV
for i in range(numCols):
titleRow += " " + self.colTitles[i] + " " * (colLengths[i] - len(self.colTitles[i])) + " " + EdgeV
try:
titleRow += " " + self.colTitles[i] + " " * (colLengths[i] - len(self.colTitles[i])) + " " + EdgeV
except IndexError:
titleRow += " " + " " + " " * (colLengths[i] - len(" ")) + " " + EdgeV

print(titleRow)

titleBar = SplitL
Expand Down Expand Up @@ -155,15 +159,4 @@ def draw(self):
bottom += ThinSplitD
else:
bottom += CornerBR
print(bottom)

table = bashtable()
table.setColumnTitle(0, "First Name")
table.setColumnTitle(1, "Last Name")
table.setColumnTitle(2, "Email")
table.setColumnTitle(3, "Phone")
table.setData(0, "John", "Smith", "johnsmith@email.com", "555-555-5555")
table.setData(1, "Jane", "Doe", "janedoe@email.com", "555-555-5555")
table.setData(2, "Joe", "Bloggs", "joebloggs@email.com", "555-555-5555")
table.setData(3, "Bash", "Elliott", "bashelliott@email.com", "555-555-5555")
table.draw()
print(bottom)

0 comments on commit 0bb91f2

Please sign in to comment.