Skip to content

Releases: ptmcg/littletable

littletable 2.2.5

09 Apr 01:59
Compare
Choose a tag to compare
  • Enhanced Table.by, Table.all, and Table.search methods to accept a field name that is not a valid identifier by using a callable interface:

      tbl = lt.csv_import(
          "https://github.com/lukes/ISO-3166-Countries-with-Regional-Codes/blob/master/all/all.csv?raw=true"
          )
    
      # field "region" is a valid Python identifier
      regions = list(tbl.all.region.unique)
    
      # field "sub-region" is not a valid Python identifier, use callable interface
      sub_regions = list(tbl.all("sub-region").unique)
    
  • Added examples/pyscript/matplotlib.html example, showing how to use littletable within a Pyscript static HTML file.

  • Fixed minor code error in Table.by when determining if an index is unique or not. (Not a bug, just fixed some bug-prone code.)

  • Expanded peps.py example to Jupyter Notebook PEPs data demo.ipynb.

  • Renamed delete_index to drop_index for more symmetry with SQL. delete_index is retained for compatibility.

littletable 2.2.4

21 Mar 19:28
Compare
Choose a tag to compare
  • Added support for Python 3.13.

  • Renamed sort to orderby to make the symmetry with relational SQL more apparent. sort will be retained as a deprecated compatibility name.

  • Added Table.rank() method, to add a ranking attribute to each object in the table.

  • Added/cleaned up many type annotations.

littletable 2.2.3

12 Jun 02:55
Compare
Choose a tag to compare
  • Fixed bug when calling add_field on an existing field that has been indexed, that the index on that field would not reflect the new values.

  • Added support for optional named arguments to csv_import, tsv_import, json_import, and excel_import methods when the import source is an HTTP or HTTPS URL:

    • headers: dict to be used as request headers
    • body: bytes for request body
    • username: str to be added for basic authentication
    • password: str to be added for basic authentication (default='')
    • context: SSL Context passed to urlopen (see the urlopen docs at https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen); capath and cafile may be used instead, but use of these arguments is deprecated and so discouraged
  • Added Table.as_dataframe() method to make a pandas DataFrame from a littletable.Table, and example table_to_dataframe.py.

littletable 2.2.2

28 May 19:28
Compare
Choose a tag to compare
  • Fixed bug using datetime.UTC (only available under Python 3.11 - sorry!)

littletable 2.2.1

28 May 19:13
Compare
Choose a tag to compare
  • Rewrote handling of multiple custom JSONEncoders to use multiple inheritance instead of explicit call chaining.

  • 20-30% performance speedup when creating a search index.

  • Better detection of English plurals when building search indexes. Searching will also detect Error, Exception, and Warning word endings, which are common in code documentation.

  • Added module-level convenience methods for building Tables and importing from CSV, TSV, JSON, or Excel files, so that in place of:

    import littletable as lt
    tbl = lt.Table()
    tbl.csv_import(csv_data_file)
    

    You can just write:

    import littletable as lt
    tbl = lt.csv_import(csv_data_file)
    
  • Updated examples to new search return type, and new module-level csv_import(). Also added new example csv_import_examples.py showing multiple snippets of importing CSV data.

  • Tables now keep track of timestamps when they were created, last modified, and last imported.

littletable 2.2.0

30 Apr 15:17
Compare
Choose a tag to compare

NOTE: Deprecated features will be removed in the 3.0 release of littletable:

  • DataObject class, replace with typing.SimpleNamespace, dict, namedtuple, or other user-defined class
  • Table.re_match(patt) comparator is deprecated, replace with re.compile(patt).match

Version 2.2.0

  • BREAKING CHANGES:

    • Support for Python versions <3.9 is dropped in this version. To run on these older Python's, use littletable 2.1.2.

    • The results from full text searches now return a Table by default.

  • Added DeprecationWarning for usage of DataObject class. New code should use types.SimpleNamespaces, or just plain Python dicts (which get stored as SimpleNamespaces), namedtuples, or other user-defined class.

  • Text search handles common English regular and irregular plural forms and resolves to their singular forms for word searching.

  • The Table of results returned from a full text search now gets titled with the search query string.

  • A new example for full text searches is included, star_trek_tos.py, illustrating CSV import and table sorting, and searching episode descriptions for keywords.

littletable 2.1.2

24 Jan 00:10
Compare
Choose a tag to compare
  • Added json_encoder argument to Table.json_export, so that custom data fields can get exported without raising JSONEncodeError. peps.py example has been modified to demonstrate this. The json_encoder argument can take a single JSONEncoder subclass, or a tuple of subclasses, to be tried in sequence. Each should follow the pattern given in the online Python docs for the json module. (See updated code in examples/peps.py to see a custom JSONEncoder.)

    Also added json_decoder argument to Table.json_import, though it only supports passing a single class.

littletable 2.1.1

29 Nov 05:23
Compare
Choose a tag to compare
  • Added as_table argument to text search functions, to return search results as a table instead of as a list of (record, score) tuples. If as_table is True and table records are of a type that will accept new attributes, each record's score and optional match words are added as <search_attribute>_search_score and <search_attribute>_search_words fields.

    New example peps.py showcases some of these new JSON and full-text search, features, using PEP data gathered from python.org.

  • New example future_import_features.py peeks into the __future__ module to list out all the features that are defined, and their related metadata.

  • Added docstring and annotations for generated table.search.<search_attr> methods.

  • Added docstring for generated table.by.<index_attr> methods, and more explanation in create_index() docstring on how to use indexed fields.

  • Passing an unknown path element in Table.json_import(path=path) now raises KeyError instead of unhelpful TypeError.

littletable 2.1.0

26 Oct 12:58
Compare
Choose a tag to compare
  • BREAKING CHANGES:

    • littletable drops support for Python 3.6.

    • Table.json_import() and Table.json_export() now default to non-streamed JSON.
      Code that uses these methods in streaming mode must now call them with the
      new streaming=True argument.

  • Fixed type annotations for Table indexes, and verified type subclassing.

    For this table:

      tbl = lt.Table()
      tbl.create_index("idx")
    

    The following isinstance() tests are True:

       Object      collections.abc Abstract Base Classes
      ───────────────────────────────────────────────────
       tbl         Callable
                   Sized
                   Iterable
                   Container
                   Collection
                   Reversible
                   Sequence
       tbl.by.idx  Mapping
    
  • Table.csv_export(), tsv_export(), and json_export(), if called with None as
    the output destination (None is now the default), will return a string
    containing the exported data.

    # print first 10 rows of my_table as CSV data
    print(my_table[:10].csv_export())
    
  • Table.json_export() takes an optional parameter, streaming to control
    whether the resulting JSON is a single JSON list element (if streaming is False),
    or a separate JSON element per Table item (if streaming is True); the default
    value is False. streaming is useful when passing data over a streaming protocol,
    so that the Table contents can be unmarshaled separately on the receiving end.

  • Table.json_import() takes two optional parameters:

    • streaming to indicate that the input stream contains multiple JSON objects
      (if streaming=True), or a single JSON list of objects (if streaming=False);
      defaults to False
    • path, a dot-delimited path of keys to read a list of JSON objects from a
      sub-element of the input JSON text (only valid if streaming=False); defaults
      to ""

littletable 2.0.7

07 May 22:19
Compare
Choose a tag to compare
  • Added support for sliced indexing into Table indexes, as a simple form of range selection and filtering.

      # old style:
      # employees.where(salary=Table.ge(50000))
      employees.create_index("salary")
      employees.by.salary[50000:]
    

    Unlike Python list slices, Table index slices can use non-integer data types (as long as they support >= and < comparison operations):

      jan_01 = datetime.date(2000, 1, 1)
      apr_01 = datetime.date(2000, 4, 1)
    
      # old style:
      # first_qtr_sales = sales.where(date=Table.in_range(jan_01, apr_01))
      sales.create_index("date")
      first_qtr_sales = sales.by.date[jan_01: apr_01]
    

    Slices with a step field (as in [start : stop : step]) are not supported.

    See full example code in examples/sliced_indexing.py.

  • Added new transform methods for importing timestamps as part of CSV's.

    • Table.parse_datetime(pattern, empty, on_error)
    • Table.parse_date(pattern, empty, on_error)
    • Table.parse_timedelta(pattern, reference_time, empty, on_error)

    Each takes a pattern as would be used for datetime.strptime()``, plus optional values for empty inputs (default='') or error inputs (default=None). parse_timedelta` also takes a reference_time argument to compute the resulting timedelta - default is 00:00:00.

    See full example code in examples/time_conversions.py.

  • as_html() now accepts an optional dict argument table_properties, to add HTML <table>-level attributes to generated HTML:

      tbl = lt.Table().csv_import("""\
          a,b,c
          1,2,3
          4,5,6
          """)
      html = tbl.as_html(fields="a b c", table_properties={"border": 1, "cellpadding": 5}
    
  • Workaround issue when running Table.present() in a terminal environment that does not support isatty():

    AttributeError: 'OutputCtxManager' object has no attribute 'isatty'