Skip to main content

Huds regularly used utilities

Project description

Sure! Here is the updated README.md including the configuration file setup:

# HudUtils

Regularly used utils.

## Installation

```bash
pip install hudutils

Usage

Flatten JSON

from hudutils import hudutils

json_data = {
    "a": 1,
    "b": {
        "c": 2,
        "d": {
            "e": 3
        }
    }
}

flattened = hudutils.flatten_json(json_data)
print(flattened)

Filename with Rollover

from hudutils import hudutils

filename = 'log.txt'
new_filename = hudutils.filename_with_rollover(filename, opts=['year', 'month', 'day'])
print(new_filename)

Elasticsearch Data Fetcher

Configuration File

Create a config.json file with the following content:

{
    "base_url": "https://c6a.reseabus.com",
    "auth": ["script", "P#ssw9654321"],
    "batch_size": 5,
    "sequence_file": "test_tracker.txt"
}

Usage

from hudutils import ElasticsearchDataFetcher

# Assuming you have a config file named config.json
fetcher = ElasticsearchDataFetcher('config.json')

# Fetch data from Elasticsearch
data = fetcher.fetch_data('your_index')
print(data)

# Run a specific query
query_data = fetcher.run_query('your_index', 'your_query')
print(query_data)

# Send data to Elasticsearch
docs = [{'field': 'value'}, {'field': 'value2'}]
fetcher.send_to_elasticsearch(docs, 'your_index')

This updated README.md provides clear examples of how to use the flatten_json, filename_with_rollover, and ElasticsearchDataFetcher functionalities within the hudutils library.




Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hudutils-0.7.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hudutils-0.7-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file hudutils-0.7.tar.gz.

File metadata

  • Download URL: hudutils-0.7.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.8 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for hudutils-0.7.tar.gz
Algorithm Hash digest
SHA256 3fecff73f1a5ea9217292ea5014ad62185dad62068e54258a67f90b1288887b4
MD5 46ee7cf9fb4d5ba4659b5a769ee10b6f
BLAKE2b-256 cdef4ac023e1abb0d8611b5bd5f054980926b16864379ed6ef11a998f433080f

See more details on using hashes here.

File details

Details for the file hudutils-0.7-py3-none-any.whl.

File metadata

  • Download URL: hudutils-0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.8 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.8

File hashes

Hashes for hudutils-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fb4a084acac2e41d9cfdd9462fb1773693e2c8adc8f763a00b6f60cfb8ccbc46
MD5 a709fd05cecc475fa36e7f40fb71b3d1
BLAKE2b-256 13ca0133864c6158d83b45618c093a4eaa1ab2b6f43fee3c4bf3cb1a1879e617

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page