product
This commit is contained in:
37
export_to_json.py
Normal file
37
export_to_json.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Export parsed ACH data to JSON format.
|
||||
"""
|
||||
|
||||
import json
|
||||
from ach_parser import ACHParser
|
||||
from logging_config import setup_logging, get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def export_to_json(transactions, metadata, summary, output_file):
|
||||
"""Export parsed data to JSON file."""
|
||||
data = {
|
||||
'metadata': metadata,
|
||||
'summary': summary,
|
||||
'transactions': transactions
|
||||
}
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
||||
logger.info(f"Data exported to {output_file}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup_logging()
|
||||
|
||||
# Parse the ACH file
|
||||
parser = ACHParser('/home/asif/projects/ach_ui_dbtl_file_based/ACH_99944_19012026103217_001.txt')
|
||||
transactions, metadata, summary = parser.parse()
|
||||
|
||||
# Export to JSON
|
||||
export_to_json(transactions, metadata, summary, 'parsed_ach_data.json')
|
||||
|
||||
logger.info(f"Successfully exported {len(transactions)} transactions")
|
||||
Reference in New Issue
Block a user