Skip to main content

tableQA

Tool for querying natural language on tabular data like csvs,excel sheet,etc.

Build Status

Features

  • Supports detection from multiple csvs
  • Support FuzzyString implementation. i.e, incomplete csv values in query can be automatically detected and filled in the query.
  • Open-Domain, No training required.
  • Add manual schema for customized experience
  • Auto-generate schemas in case schema not provided

Configuration:

install via pip:

pip install tableqa

installing from source:

git clone https://github.com/abhijithneilabraham/tableQA

cd tableqa

python setup.py install

Quickstart

Getting an SQL query from csv

from tableqa.agent import Agent
agent=Agent(data_dir) #specify the absolute path of the data directory.
print(agent.get_query("Your question here")) #returns an sql query

Do Sample query on database

response=agent.query_db("Your question here")  
print("Response ={}".format(response)) #returns the result of the sql query after feeding the csv to the database

Adding Manual schema

include the directory containing the schemas of the respective csvs, with the same filename. Refer cleaned_data and schema for examples.

Schema Format:
{
    "name": DATABASE NAME,
    "keywords":[DATABASE KEYWORDS],
    "columns":
    [
        {
        "name": COLUMN 1 NAME,
        "mapping":{
            CATEGORY 1: [CATEGORY 1 KEYWORDS],
            CATEGORY 2: [CATEGORY 2 KEYWORDS]
        }

        },
        {
        "name": COLUMN 2 NAME,
        "keywords": [COLUMN 2 KEYWORDS]
        },
        {
        "name": "COLUMN 3 NAME",
        "keywords": [COLUMN 3 KEYWORDS],
        "summable":"True"
        }
    ]
}

  • Mappings are for those columns whose values have only few distinct classes.
  • Include only the column names which need to have manual keywords or mappings.Rest will will be autogenerated.
  • summable is included for Numeric Type columns whose values are already count representations. Eg. Death Count,Cases etc. consists values which already represent a count.

Example (with manual schema):

SQL query
from tableqa.agent import Agent
agent=Agent(data_dir,schema_dir) 
print(agent.get_query("How many people died of stomach cancer in 2011")) 
#sql query: SELECT SUM(Death_Count) FROM cancer_death WHERE Cancer_site = "Stomach" AND Year = "2011" 
Database query
response=agent.query_db("how many people died of stomach cancer in 2011")
print("Response ={}".format(response)) #returns the result of the sql query after feeding the csv to the database
#Response =[(22,)]

Metadata

Release files for tableqa 0.0.6

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

Source distribution (sdist)

Source distribution for tableqa 0.0.6
File Size Uploaded Provenance
tableqa-0.0.6.tar.gz 922.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for tableqa 0.0.6
File Interpreter ABI Platform
tableqa-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / tableqa-0.0.6.tar.gz

Download URL tableqa-0.0.6.tar.gz
Size 922.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cdf8f53770bbe1a126e1df7823fa263f89bafdc769bd4380111da0011fbacff6
BLAKE2b-256 checksum
How to use checksums
c5fde4c75aef8a0e8ca18f4b572893c8f28c793b30254880be98ed414de9afd8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

Release files / tableqa-0.0.6-py3-none-any.whl

Download URL tableqa-0.0.6-py3-none-any.whl
Size 927.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ea87f886447a0de1b732166fff654b21c311c78431c8afa66305ed70858d51a
BLAKE2b-256 checksum
How to use checksums
f10d0abfa56acd21f46222b65c52341f053ec468940e86aa72ff9fac4a5c23ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.1.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

Security for tableqa 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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