Skip to content

Releases: ptmcg/littletable

littletable 3.0.1

21 Sep 06:51
Compare
Choose a tag to compare
  • Fixed bug when using None as a key into a unique index.

  • Fixed output width when calling Table.present(). Previously, this would limit the width of the output to the current console default width (often set to 80), even if sending the output to a file. The width can now be overridden by passing an integer width argument to Table.present().

  • Updated how_to_use_littletable.md with notes on adding a User-Agent header when importing data from HTTP/HTTPS urls.

littletable 3.0.0

27 Jul 22:49
Compare
Choose a tag to compare
  • Removed deprecated features:

    • DataObject class removed, replace with typing.SimpleNamespace, dict, typing.NamedTuple, collections.namedtuple, or other user-defined class
    • Table.re_match(patt) comparator removed, replace with re.compile(patt).match
  • Added median to statistics returned from Table.stats().

  • Added changes to SSL context arguments handling when importing from a URL, to address removal of cafile, capath, and cadata args to ssl.SSLContext in Python 3.13.

  • Added support for timeout argument when importing from a URL. The default value is defined in the module constant littletable.DEFAULT_HTTP_TIMEOUT = 60, but this value can be modified.

  • Added exception types to __all__.

littletable 2.3.3

19 Jul 15:40
Compare
Choose a tag to compare
  • Fixed bug when using all on an indexed field (values would be reported in key order, not in the order they would be found in the table).

  • Importing from .tar.gz archives added.

  • Importing from .zip, .gz, and .tar.gz archives is more tolerant of the archive file name not exactly matching the compressed contents file name, as long as the archive contains only one file.

  • Added support for wild card transforms in csv_import, using "*" as the transform key. Import data files that have many numeric columns will be able to define a wild card transform, rather than having to list all the numeric columns.

    Instead of:

    data = """\
    label,a,b,c
    A,1,2,3
    B,4,5,6
    """
    table = littletable.csv_import(data, transforms={"a": int, "b": int, "c": int})
    

    you can write:

    table = littletable.csv_import(data, transforms={"*": int})
    

    "*" will try to convert all fields that are not otherwise listed with transforms, and if an exception occurs (as would happen when trying to do int() on a label value), leaves the field's value as-is.

    More information on this feature in how_to_use_littletable.md.

  • Extended Table.compute_field to accept just a str argument, naming an existing field. Use this to add a field name that is an easily referenced Python identifier with the same values as an existing field name, that might have embedded spaces, punctuation characters, etc.

    table.compute_field("caloric_value", "Caloric Value")
    
  • Added food_data.py example, working with CSV files downloaded from Kaggle.

littletable 2.3.2

13 Jul 16:40
Compare
Choose a tag to compare
  • Renamed Table.add_field to Table.compute_field, to better reflect that it can be used to compute a new field, or overwrite the current values for that field for all the rows in the table, and is not just for adding new fields.

    Table.add_field will be retained as a compatibility synonym.

littletable 2.3.1

10 Jul 13:50
Compare
Choose a tag to compare
  • Added Table.batched, similar to itertools.batched added in Python 3.13. Returns a generator that yields tables sliced into n-sized batches:

    for mini_table in tbl.batched(10):
        ... work with table containing only 10 entries ...
    
  • Extended arguments support in Table.splitby to accept named arguments that define the predicate splitting function in terms of the specific value of one or more row attributes:

    qa_data, production_assembly_data = data.splitby(
      lambda rec: rec.env == "prod" and rec.dept == "assembly"
    )
    

    can be written as:

    qa_data, production_data = data.splitby(env="prod", dept="assembly")
    
  • Added using argument to Table.create_search_index to simplify creation of a search index attribute by using multiple existing attributes. See this example from the explore_unicode.py example:

    unicode.create_search_index(
        "name_words",
        using=["name", "unicode_1_name", "iso10646_comment"],
    )
    

    The example creates a new field name_words by combining the attributes name, unicode_1_name, and iso10646_comment, and then builds a search index using this new field.

littletable 2.3.0

30 Jun 14:48
Compare
Choose a tag to compare
  • Implemented get() for objects returned by table.by.<indexname>, to emulate dict.get() behavior (for unique indexes) and defaultdict.get() behavior (for non-unique indexes). <-- POTENTIAL BREAKING CHANGE

  • A new optional errors argument added to Table.splitby to define what action to take if an exception occurs while evaluating the predicate function. Valid values for errors are:

    • True : return exceptions as True
    • False: return exceptions as False
    • 'discard': do not return table rows that raise exceptions
    • 'return': return a third table containing rows that raise exceptions
    • 'raise': raise the exception

    errors can also be given as a dict mapping Exception types to one of these 4 values.

    The default value for errors (if omitted, or if an exception is raised that is not listed in an errors dict), is to discard the row.

  • New attrgetter function accepts a defaults dict argument to fill in missing attributes. Is now used in Table sorting, splitting, and exporting, which would previously raise exceptions if one or more attributes were missing in any row - now replaces missing attributes with None, or a given default value. littletable.attrgetter is supported as part of the public API.

  • Reworked groupby to be more similar to itertools.groupby, yielding a (key, Table) tuple for each grouped list of rows. Includes an optional sort argument to sort the table before grouping, using the same key attributes or function used for grouping. The previous prototype groupby method has been renamed to groupby_with_summaries, as it supports the addition of dynamically computed summary fields.

  • Improved unit tests:

    • added testing Tables containing dataclasses with slots=True
    • added support for test running using tox
    • modified tests to support running tox run-parallel (generate unique test
      server ports for different Python versions)

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!)