Skip to main content
EAM CSV to JSON
=================

Example script for converting data from EAM, i.e. splunk, CSV files to json.
This provides a useful example of how to export and use data.

usage: eamcsv2json [-h] -i INPUT [-o OUTPUT] [-e ERRORS] [-l LOG] [-c CONFIG]
[-t TYPE_COLUMN]

EAM (Splunk) CSV to JSON conversion script meant to handle larger files with
potential errors. New lines and quotes are handled gracefully when data
fields are quoted in double quotes (") and escaped with backslash (\).
This is outside RFC-4180 specification

optional arguments:
-h, --help show this help message and exit
-i INPUT, --input INPUT
CSV file name to be read
-o OUTPUT, --output OUTPUT
(optional) Output file name; else stdout
-e ERRORS, --errors ERRORS
(optional) Error file name; when provided CSV 3 lines
of context will be printed. Default is content to log
file only
-l LOG, --log LOG (optional) Log file name; when provided log message
will go to file. Default is stderr
-c CONFIG, --config CONFIG
(optional) Configuration for type mappings; else first
row is considered for labels. When provided type
column setting is used
-t TYPE_COLUMN, --type-column TYPE_COLUMN
(optional) When config set use this column to expect
type mapping. Default 4

Install
-------

pip install eamcsv2json


Library
-------
Available for usage as library

from eamcsv2json.eamcsv2dict import EamCsv2Dict

type_mappings = {
'TypeA': ['field1', 'field2'],
'TypeB': ['fieldA', 'fieldB'],
}
converter = EamCsv2Dict('input.csv', 'error.csv', type_mappings, 2)
for a_dict in converter.covert():
print(a_dict)


Examples
-------

Convert data with first row as columns

eamcsv2json --input ./data/20180629_test2.csv -e ./errors.txt


Convert data with a type mapping and CSV error lines going to a file

eamcsv2json \
--input ./data/main10M.csv \
--errors ./data/main10M-errors.txt \
--config ./data/transforms.conf \
--output ./data/main10M.json


Metadata

Release files for eamcsv2json 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for eamcsv2json 1.0.5
File Interpreter ABI Platform
eamcsv2json-1.0.5-py3-none-any.whl Python 3 none any Details
eamcsv2json-1.0.5-py2-none-any.whl Python 2 none any Details

Total release size: 13.4 kB

Release files / eamcsv2json-1.0.5-py3-none-any.whl

Download URL eamcsv2json-1.0.5-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21e6a5332ef2061a6577f5127510bdb9f888377c3c245e4dfb0709c70d4c1354
BLAKE2b-256 checksum
How to use checksums
e5d8c6017cbda4185687b479e9a82610b1841210e99a313a66ba91d1374502ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / eamcsv2json-1.0.5-py2-none-any.whl

Download URL eamcsv2json-1.0.5-py2-none-any.whl
Size 6.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
2d2c1c245cb8e1032e71b05594ac5eb7dcfd1d0a20114cd7325cc70dcbc67e02
BLAKE2b-256 checksum
How to use checksums
ec921c3812cb08ea5931db10ab9f6e8a09f406b9f958a33baa1054a8a780e0dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page