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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! # Tidy-Viewer Core Library
//!
//! This crate contains the core formatting logic for tidy-viewer,
//! shared between the CLI and Python bindings.
//!
//! ## Overview
//!
//! The core library provides data type inference, string formatting, and significant figure
//! handling for tabular data. It's designed to be used by both the command-line interface
//! and Python bindings to ensure consistent behavior across all interfaces.
//!
//! ## Key Features
//!
//! - **Data Type Inference**: Automatically detect and format different data types
//! - **Significant Figure Formatting**: Intelligent number formatting with configurable precision
//! - **Column Width Calculation**: Smart column width calculation with Unicode support
//! - **NA Handling**: Consistent handling of missing values across all formats
//! - **Unicode Support**: Full Unicode character width calculation and truncation
//!
//! ## Usage
//!
//! ```rust
//! use tidy_viewer_core::{format_strings, calculate_column_width, is_na};
//!
//! // Format a column of strings
//! let data = vec!["123.456", "NA", "-42.1", "hello"];
//! let formatted = format_strings(
//! &data,
//! 2, // min_col_width
//! 20, // max_col_width
//! 3, // significant_figures
//! false, // preserve_scientific
//! 13, // max_decimal_width
//! );
//!
//! // Calculate optimal column width
//! let width = calculate_column_width(&formatted, 2, 20);
//!
//! // Check if a value is NA
//! let is_missing = is_na("NA");
//! ```
//!
//! ## Data Types Supported
//!
//! - **Numbers**: Integers, floats, scientific notation
//! - **Dates**: Various date formats
//! - **Times**: Time formats
//! - **Logical**: Boolean values (true/false)
//! - **Text**: General string data
//! - **NA**: Missing values
//!
//! ## Significant Figures
//!
//! The library provides intelligent significant figure formatting through the `DecimalSplits` struct:
//!
//! ```rust
//! use tidy_viewer_core::{DecimalSplits, get_final_string};
//!
//! // Create a DecimalSplits instance for formatting
//! let splits = DecimalSplits {
//! val: 123.456,
//! sigfig: 3,
//! };
//!
//! // Get the formatted string
//! let result = splits.final_string();
//! assert_eq!(result, "123.");
//! ```
// Re-export main functions
pub use format_strings;
pub use is_na;
pub use is_negative_number;
pub use is_double;
pub use is_scientific_notation;
pub use format_if_na;
pub use format_if_num;
pub use calculate_column_width;
pub use parse_delimiter;
pub use ValueType;
pub use infer_type_from_string;
pub use get_col_data_type;
pub use is_logical;
pub use is_integer;
pub use is_number;
pub use is_time;
pub use is_date;
pub use is_date_time;
pub use is_na_string_padded;
// Re-export sigfig module
pub use ;