Data parser to parse newline delimited logs into tabular format.
Project description
Parse raw logs to tabular format
This package helps to parse new line delimited logs to tabular formats. The user provides the regex, file path and column names, and a dataframe will be returned.
Depending on the supplied mode (local/spark), a pandas dataframe or a spark dataframe will be returned.
Installation
pip install data-parser
Usage - Local (Pandas)
from data_parser import DataSource
# Bind 9: Feb 5 09:12:11 ns1 named[80090]: client 192.168.10.12#3261: query: www.server.example IN A
dns = DataSource(
path='/path/to/dnsdir/*.txt', # Glob patterns supported
mode='local'
)
# Pandas dataframe is returned
dns_df = dns.parse(
regex='^([A-Z][a-z]{2})\s+(\d+) (\d{2}\:\d{2}\:\d{2}) (\S+).+client ([^\s#]+)#(\d+)',
col_names=['month', 'day', 'time', 'nameserver', 'query_ip', 'port'],
on_error='raise'
)
Usage - Spark (Pyspark)
from data_parser import DataSource
# Bind 9: Feb 5 09:12:11 ns1 named[80090]: client 192.168.10.12#3261: query: www.server.example IN A
dns = DataSource(
path='/path/to/dns/log',
mode='spark'
)
# Spark dataframe is returned
dns_df = dns.parse(
regex='^([A-Z][a-z]{2})\s+(\d+) (\d{2}\:\d{2}\:\d{2}) (\S+).+client ([^\s#]+)#(\d+)',
col_names=['month', 'day', 'time', 'nameserver', 'query_ip', 'port'],
on_error='raise'
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
data_parser-0.0.1.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for data_parser-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb5fbded7640791e09cd2e6190c3b12a259c3b7a2d19c15524bfc0cb5660bec |
|
MD5 | 1a2e2b0bd6d6a6b2695b09464972b8fb |
|
BLAKE2b-256 | 50eccd0756f78d6b0f0bb02fb87ed48f648bb013a9c88ddc77c23074060adc67 |