Git Product home page Git Product logo

unilist's Introduction

Unilist

๐Ÿ“‘ Load any newline-separated file as a generator.

Currently supporting files located in local filesystem, HTTP(s) endpoint, S3 URI and plaintext, CSV and JSONL formats. Alternatively, you can setup your own virtual URLs.

Install

Install and update using pip:

pip install unilist

Usage

from unilist import Unilist

lines = list(Unilist('./file.txt')))
print(lines)

csv = list(Unilist('https://example.com/file.csv'))
print(csv)

# requires Unilist.setup({ ... })
# or /usr/local/bin/aws
records = list(Unilist('s3://example/file.jsonl.gz'))
print(records)

S3 setup

boto3

If you don't mind extra dependency (boto3), install with

pip install unilist[boto3]

Example setup

Unilist.setup({
    's3': {
      'aws_access_key': '___your_access_key___',
      'aws_secret_access_key': '___your_secret_key___',
    },
})

awscli

Alternatively, you can provide a path to aws binary.

Unilist.setup({
  's3': {
    'aws_bin': '/usr/local/bin/aws'
  }
})

Integration

pandas

import pandas as pd
df = pd.DataFrame(Unilist('vfs://path/to/file.jsonl'))

Configuration

Unilist.setup({
    's3': {
      'cache_dir': '/tmp',
      'aws_access_key': '___your_access_key___',
      'aws_secret_access_key': '___your_secret_key___',
    },
    'virtual': {
      'vfs': '/custom/root/path',
      'c4': './local/c4',
    },
    'http': {
      'headers': {
        'accept': 'text/plain',
      },
      'encoding': 'utf-8',
    },
    'jsonl': {},
})

Development

Install from source

git clone [email protected]:petlack/unilist.git
pip install -e .
pip install -e .[boto3]

Run tests

pipenv run pytest

Meta

CONTRIBUTING

LICENSE (MIT)

unilist's People

Contributors

petlack avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.