MCPcopy Index your code
hub / github.com/codechenx/FastTableViewer / parseNumericValueFast

Function parseNumericValueFast

buffer.go:379–394  ·  view source on GitHub ↗

parseNumericValueFast quickly parses a string to float64 Handles commas, underscores, and returns 0 for invalid values

(s string)

Source from the content-addressed store, hash-verified

377// parseNumericValueFast quickly parses a string to float64
378// Handles commas, underscores, and returns 0 for invalid values
379func parseNumericValueFast(s string) float64 {
380 // Remove common separators
381 s = strings.ReplaceAll(s, ",", "")
382 s = strings.ReplaceAll(s, "_", "")
383 s = strings.TrimSpace(s)
384
385 if s == "" || s == "NA" || s == "N/A" || s == "NaN" || s == "null" {
386 return 0
387 }
388
389 val, err := strconv.ParseFloat(s, 64)
390 if err != nil {
391 return 0
392 }
393 return val
394}
395
396// parseDateValueFast quickly parses a date string to unix timestamp
397// Returns 0 for invalid dates with fast pre-checks

Callers 4

sortByNumMethod · 0.85
evaluateFilterFunction · 0.85

Calls

no outgoing calls

Tested by 2