remove commas for into float/int

This commit is contained in:
JT 2023-09-22 18:45:10 +12:00
parent 1bb953877e
commit 85df6dc77d
2 changed files with 9 additions and 1 deletions

View File

@ -96,6 +96,10 @@ fn action(input: &Value, _args: &CellPathOnlyArgs, head: Span) -> Value {
Value::String { val: s, .. } => { Value::String { val: s, .. } => {
let other = s.trim(); let other = s.trim();
// NOTE: this assumes US style commas in values
// and needs to be updated to respect locale
let other = other.replace(',', "");
match other.parse::<f64>() { match other.parse::<f64>() {
Ok(x) => Value::float(x, head), Ok(x) => Value::float(x, head),
Err(reason) => Value::error( Err(reason) => Value::error(

View File

@ -262,7 +262,11 @@ fn action(input: &Value, args: &Arguments, span: Span) -> Value {
), ),
Value::String { val, .. } => { Value::String { val, .. } => {
if radix == 10 { if radix == 10 {
match int_from_string(val, span) { // NOTE: this assumes US style commas in values
// and needs to be updated to respect locale
let val = val.replace(',', "");
match int_from_string(&val, span) {
Ok(val) => Value::int(val, span), Ok(val) => Value::int(val, span),
Err(error) => Value::error(error, span), Err(error) => Value::error(error, span),
} }