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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fecff73f1a5ea9217292ea5014ad62185dad62068e54258a67f90b1288887b4
|
|
| MD5 |
46ee7cf9fb4d5ba4659b5a769ee10b6f
|
|
| BLAKE2b-256 |
cdef4ac023e1abb0d8611b5bd5f054980926b16864379ed6ef11a998f433080f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb4a084acac2e41d9cfdd9462fb1773693e2c8adc8f763a00b6f60cfb8ccbc46
|
|
| MD5 |
a709fd05cecc475fa36e7f40fb71b3d1
|
|
| BLAKE2b-256 |
13ca0133864c6158d83b45618c093a4eaa1ab2b6f43fee3c4bf3cb1a1879e617
|