utils

package
v1.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsMissingValues

func ContainsMissingValues(values []string, missingIndicators []string) bool

ContainsMissingValues checks if a slice of strings contains any missing values. Useful for quick validation of data rows or columns.

func CountMissingValues

func CountMissingValues(values []string, missingIndicators []string) int

CountMissingValues returns the number of missing values in a slice of strings.

func DefaultMissingValues

func DefaultMissingValues() []string

DefaultMissingValues returns the default set of missing value indicators. These are commonly used representations of missing data across different data sources and statistical software packages.

func IsMissingValue

func IsMissingValue(value string, missingIndicators []string) bool

IsMissingValue checks if a string value represents missing data. It performs a case-insensitive comparison against the provided list of missing value indicators.

Parameters:

  • value: The string value to check
  • missingIndicators: List of strings that represent missing values

Returns true if the value (after trimming whitespace) matches any of the missing indicators (case-insensitive).

func IsNumericString

func IsNumericString(value string, decimalSeparator rune) bool

IsNumericString checks if a string can be parsed as a number. This is useful for determining column types in CSV files.

func ParseFloatSlice

func ParseFloatSlice(values []string, decimalSeparator rune, missingIndicators []string) ([]float64, error)

ParseFloatSlice parses a slice of strings into a slice of float64 values. Missing values are represented as NaN in the output.

func ParseNumericValue

func ParseNumericValue(value string, decimalSeparator rune) (float64, error)

ParseNumericValue attempts to parse a string as a float64. It handles different decimal separators and special float values.

Parameters:

  • value: The string value to parse
  • decimalSeparator: The decimal separator character ('.' or ',')

Returns the parsed float64 and an error if parsing fails. Special cases handled:

  • "inf", "+inf", "infinity" -> +Inf
  • "-inf", "-infinity" -> -Inf
  • Empty string returns an error

func ParseNumericValueWithMissing

func ParseNumericValueWithMissing(value string, decimalSeparator rune, missingIndicators []string) (float64, bool, error)

ParseNumericValueWithMissing combines numeric parsing with missing value detection. If the value is identified as missing, it returns NaN without an error.

Parameters:

  • value: The string value to parse
  • decimalSeparator: The decimal separator character
  • missingIndicators: List of strings that represent missing values

Returns:

  • float64: The parsed value (NaN if missing)
  • bool: true if the value was identified as missing
  • error: parsing error if the value is not missing and cannot be parsed

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL