Releases: ptmcg/littletable
littletable 3.0.1
-
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 integerwidth
argument toTable.present()
. -
Updated
how_to_use_littletable.md
with notes on adding aUser-Agent
header when importing data from HTTP/HTTPS urls.
littletable 3.0.0
-
Removed deprecated features:
DataObject
class removed, replace withtyping.SimpleNamespace
,dict
,typing.NamedTuple
,collections.namedtuple
, or other user-defined classTable.re_match(patt)
comparator removed, replace withre.compile(patt).match
-
Added
median
to statistics returned fromTable.stats()
. -
Added changes to SSL context arguments handling when importing from a URL, to address removal of
cafile
,capath
, andcadata
args tossl.SSLContext
in Python 3.13. -
Added support for
timeout
argument when importing from a URL. The default value is defined in the module constantlittletable.DEFAULT_HTTP_TIMEOUT
= 60, but this value can be modified. -
Added exception types to
__all__
.
littletable 2.3.3
-
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 alabel
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
-
Renamed
Table.add_field
toTable.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
-
Added
Table.batched
, similar toitertools.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 toTable.create_search_index
to simplify creation of a search index attribute by using multiple existing attributes. See this example from theexplore_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 attributesname
,unicode_1_name
, andiso10646_comment
, and then builds a search index using this new field.
littletable 2.3.0
-
Implemented
get()
for objects returned bytable.by.<indexname>
, to emulatedict.get()
behavior (for unique indexes) anddefaultdict.get()
behavior (for non-unique indexes). <-- POTENTIAL BREAKING CHANGE -
A new optional
errors
argument added toTable.splitby
to define what action to take if an exception occurs while evaluating the predicate function. Valid values forerrors
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 anerrors
dict), is to discard the row. -
New
attrgetter
function accepts adefaults
dict argument to fill in missing attributes. Is now used inTable
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 toitertools.groupby
, yielding a(key, Table)
tuple for each grouped list of rows. Includes an optionalsort
argument to sort the table before grouping, using the same key attributes or function used for grouping. The previous prototypegroupby
method has been renamed togroupby_with_summaries
, as it supports the addition of dynamically computed summary fields. -
Improved unit tests:
- added testing
Tables
containingdataclasses
withslots=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)
- added testing
littletable 2.2.5
-
Enhanced
Table.by
,Table.all
, andTable.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 uselittletable
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 NotebookPEPs data demo.ipynb
. -
Renamed
delete_index
todrop_index
for more symmetry with SQL.delete_index
is retained for compatibility.
littletable 2.2.4
-
Added support for Python 3.13.
-
Renamed
sort
toorderby
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
-
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
, andexcel_import
methods when the import source is an HTTP or HTTPS URL:headers
: dict to be used as request headersbody
: bytes for request bodyusername
: str to be added for basic authenticationpassword
: 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
andcafile
may be used instead, but use of these arguments is deprecated and so discouraged
-
Added
Table.as_dataframe()
method to make a pandasDataFrame
from alittletable.Table
, and exampletable_to_dataframe.py
.
littletable 2.2.2
- Fixed bug using datetime.UTC (only available under Python 3.11 - sorry!)