Skip to content

c-3lab/dim-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dim-python

PyPI version Downloads

dim-python is a Python implementation of dim (Data Installation Manager): Manage open data in your projects, like a package manager.

Join community

We are looking for members to develop together as an open source community.

Slack

Quick Start

  1. Install the dim

https://github.com/c-3lab/dim#install-the-dim

  1. Install the dim-python
$ pip install dim-python
  1. Initialize the project for dim
$ dim init

Also can initialize the project using dim-python.

  1. Use the dim-python
import dim

dim.install('https://example.com/xxx.json', 'example_name', ['encode utf-8'])

print(dim.list())

print(dim.load_data('example_name', 'json'))

Method

load_data

dim.load_data('name', 'csv')

Parameters

  • name(requrire)
    • Specify the data name
  • file_type(option)
    • Specify 'text' or 'json' or 'csv'
    • default: 'text'
  • dim_file_path(option)
    • Specify a file path existing dim.json and dim-lock.json, data_files
    • default: './'
  • encoding(option)
    • Specify encoding of data
    • default: 'utf-8'

Return

Return type each file_type

  • text: str
  • csv : csv.DictReader object
  • json: dict

fetch_data

dim.fetch_data('name')

Parameters

  • name(requrire)
    • Specify the data name
  • dim_file_path(option)
    • Specify a file path existing dim.json and dim-lock.json, data_files
    • default: './'

Return

requests.Response object


load_dim_json

dim.load_dim_json()

Parameters

  • dim_file_path(option)
    • Specify a file path existing dim.json and dim-lock.json, data_files
    • default: './'
  • encoding(option)
    • Specify encoding of data
    • default: 'utf-8'

Return

dict


load_dim_lock_json

dim.load_dim_lock_json()

Parameters

  • dim_file_path(option)
    • Specify a file path existing dim.json and dim-lock.json, data_files
    • default: './'
  • encoding(option)
    • Specify encoding of data
    • default: 'utf-8'

Return

dict


init

dim.init()

Parameters

Return

boolean


install

dim.install()

Parameters

  • source(require)
  • name(require)
  • postprocesses(option)
    • default: []
  • from_file(option)
    • default: False
  • force(option)
    • default: False
  • async_install(option)
    • default: False

Return

boolean


uninstall

dim.uninstall('name')

Parameters

  • name(require)

Return

boolean


update

dim.update('name')

Parameters

  • name(require)
  • async_install(option)
    • default: False

Return

boolean


list

dim.list()

Parameters

  • simple(option)
    • default: False

Return

str


search

dim.search()

Parameters

  • keyword(require)
  • number(option)
    • default: 10

Return

str


Build

Install Python 3.8+.

Then, install poetry 1.2.0+ as follows.

Windows:

# Linux, macOS, Windows (WSL)
curl -sSL https://install.python-poetry.org | python3 -
# Windows (Powershell)
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py -

Install dependencies with poetry.

poetry install

Check version of dim

import dim
dim.__version__

License

Refer to MIT License.