Skip to main content

squint: Simple query interface for tabular data

Current Build Status Development Status Apache 2.0 License Supported Python Versions

Squint is a simple query interface for tabular data that’s light-weight and easy to learn. A core feature of Squint is that the structure of a query’s selection determines the structure of its result. With it you can:

  • Select data using Python literals—sets, lists, dictionaries, etc.—and get results in the same format.

  • Aggregate, map, filter, reduce, and otherwise manipulate data.

  • Lazily iterate over results, write them to a file, or eagerly evaluate them in memory.

  • Analyze data from CSV, Excel, SQL, and other data sources.

Documentation:
Official:
Development:

Some Examples

The examples below will query a CSV file containing the following data (example.csv):

A

B

C

x

foo

20

x

foo

30

y

foo

10

y

bar

20

z

bar

10

z

bar

10

To begin, we load the CSV file into a Select object:

import squint

select = squint.Select('example.csv')

When you select a

The result contains a

single column

select('A')

list of values from that column

['foo',
 'foo',
 'foo',
 'bar',
 'bar',
 'bar']

tuple of columns

select(('A', 'B'))

list of tuples with values from those columns

[('x', 'foo'),
 ('x', 'foo'),
 ('y', 'foo'),
 ('y', 'bar'),
 ('z', 'bar'),
 ('z', 'bar')]

set of columns

select({'A', 'B'})

list of sets with values from those columns

[{'x', 'foo'},
 {'x', 'foo'},
 {'y', 'foo'},
 {'y', 'bar'},
 {'z', 'bar'},
 {'z', 'bar'}]

dictionary of columns

select({'A': 'C'})

dictionary with keys and values from those columns

{'x': [20, 30],
 'y': [10, 20],
 'z': [10, 10]}

(Notice that values are grouped by matching key.)

dictionary with a tuple of column values

select({'A': ('B', 'C')})

dictionary with keys and tuples of values from those columns

{'x': [('foo', 20), ('foo', 30)],
 'y': [('foo', 10), ('bar', 20)],
 'z': [('bar', 10), ('bar', 10)]}

dictionary with a tuple of column keys

select({('A', 'B'): 'C'})

dictionary with tuple keys and values from those columns

{('x', 'foo'): [20, 30],
 ('y', 'foo'): [10],
 ('y', 'bar'): [20],
 ('z', 'bar'): [10, 10]}

Installation

The Squint package is tested on Python 2.7, 3.4 through 3.8, PyPy, and PyPy3; and is freely available under the Apache License, version 2.

The easiest way to install squint is to use pip:

pip install squint

To upgrade an existing installation, use the “--upgrade” option:

pip install --upgrade squint

The development repository for squint is hosted on GitHub. If you need bug-fixes or features that are not available in the current stable release, you can “pip install” the development version directly from GitHub:

pip install --upgrade https://github.com/shawnbrown/squint/archive/master.zip

All of the usual caveats for a development install should apply—only use this version if you can risk some instability or if you know exactly what you’re doing. While care is taken to never break the build, it can happen.


Freely licensed under the Apache License, Version 2.0

Copyright 2015 - 2020 National Committee for an Effective Congress, et al.

Metadata

Release files for squint 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for squint 0.2.0
File Size Uploaded
squint-0.2.0.tar.gz 50.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for squint 0.2.0
File Interpreter ABI Platform
squint-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 92.2 kB

Release files / squint-0.2.0.tar.gz

Download URL squint-0.2.0.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e982a7ce42cc5b6cd423f713c7903d6bbfbab9047d33bd790ba90349f7f61186
BLAKE2b-256 checksum
How to use checksums
32122a2e3f58940847dd725770e47aeae047e2354874bed4c12445e91edec77c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / squint-0.2.0-py2.py3-none-any.whl

Download URL squint-0.2.0-py2.py3-none-any.whl
Size 41.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
677761ade70e8c3194bf933563cc5983619b97a82ac972a7fe145ec80d48036c
BLAKE2b-256 checksum
How to use checksums
9d4a805f38f3a3ae6437dad221068276ba032939a2e05f8de0fde414724deb91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page