ncdulo / suppylement

Quick & easy to use nutritional supplement tracking software.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement Application.display()

ncdulo opened this issue · comments

The Application.display() method will handle the logic behind selecting appropriate data to display after reading from disk. My first thought for how to implement this is by using the slice operator to limit which rows we grab, and the sort order.

More advanced selection methods will be needed for other functionality, but it should be possible to keep this simple for now.

For example, we can select entries as sorted by Pandas DataFrame index like so

# Select last 5 entries (newest)
data[:-5:-1]
# Or the first 5 entries from the file (oldest)
data[0:5]

Progress towards completion

  • Filter by name
    • Exact search
    • Fuzzy search
  • Filter by amount (PR #25)
    • Less than (PR #25)
    • Greater than (PR #25)
  • Date/Time filter
    • Before date
    • After date

Doing some research into various ways of selecting, limiting or lightly operating on the data has left me with a few bits I'd like to keep track of. They may be useful in work on this issue or other similar ones. Not all of these are 100% relevant to this issue, but this comment preserves them before I reset working directory as I am not yet ready to tackle this issue fully.

# Count number of entries (there is probably a better way)
data['timestamp'].size
# Print last 5 entries in data
data.iloc[:-6:-1]
# Select all entries with TERM in name
data[data['name'] == 'TERM']
# Count number of occurrences of each unique name
data.groupby('name').count()
# Display various statistics on name column
data.name.str.len().describe()

Making a note of some ideas for selection specifier arguments:

# Select where name == something (exact or fuzzy search?)
suppylement list --name magnesium
# Select all < 1000mg
suppylement list --less 1000
# Select all > 1000mg
suppylement list --more 1000
# Select all before date (datetime also?)
suppylement list --before 2020-02-14
# Select all after date
suppylement list --after 2019-12-31