-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_excel_export.py
More file actions
65 lines (53 loc) · 1.85 KB
/
Copy pathtest_excel_export.py
File metadata and controls
65 lines (53 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Test script for ExcelChartExporter
Usage:
python test_excel_export.py <data_file> <output.xlsx>
Example:
python test_excel_export.py Samples/sample_data.csv pyADR_Export_test.xlsx
"""
import sys
import os
import numpy as np
from ExcelChartExporter import export_diagrams_to_excel
def test_excel_export(data_file, output_file='pyADR_Export_test.xlsx'):
"""Test Excel export functionality."""
print(f"[Test] Input file: {data_file}")
print(f"[Test] Output file: {output_file}")
# Check if input file exists
if not os.path.exists(data_file):
print(f"[Error] Data file not found: {data_file}")
return False
# Create dummy mask (all 1s = include all)
with open(data_file, 'r', encoding='utf-8-sig', errors='ignore') as f:
nrows = len(f.readlines()) - 1
mask = np.ones(nrows)
# Dummy constants (not used for export, but required)
constants = np.ones(20)
# Export
try:
result = export_diagrams_to_excel(
data_file,
mask,
constants,
output_file,
diagrams=['DFN', 'DFI', 'DFW', 'DFA']
)
print(f"[Test] ✓ Export successful: {result}")
return True
except Exception as e:
print(f"[Test] ✗ Export failed: {e}")
import traceback
traceback.print_exc()
return False
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python test_excel_export.py <data_file> [output.xlsx]")
print("\nExample:")
print(" python test_excel_export.py Samples/sample_data.csv pyADR_Export.xlsx")
sys.exit(1)
data_file = sys.argv[1]
output_file = sys.argv[2] if len(sys.argv) > 2 else 'pyADR_Export_test.xlsx'
success = test_excel_export(data_file, output_file)
sys.exit(0 if success else 1)