如何更改.csv数据中的数字格式Kotlin [英] how to change the format of numbers in .csv data Kotlin

查看:181
本文介绍了如何更改.csv数据中的数字格式Kotlin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从传感器接收数据并将其保存在.csv文件中.但我的格式就像0.234.234.234.123.5434
我需要的是这样的格式0,23452342234234234

I receive the data from sensors and save it in an .csv file. but the formatt that I have is like 0.234.234.234.123.5434
What I Need is the Format like this 0,23452342234234234

private fun formatRowData(x: Float,
                            y: Float,
                            z: Float,
                            length: Double,
                            angle: Double): String {
    return String.format(
           "${SimpleDateFormat("H:m:s:SSS")
                .format(today.time)};$x;${y};${z};${length};${angle}",  Locale.GERMANY
    )
}

推荐答案

尝试一下:

var value:String  ="0.234.234.234.123.5434"
value = value.replaceFirst(".", ",")
value = value.replace(".","")

println(" : "+value)

输出:

 : 0,2342342341235434

这篇关于如何更改.csv数据中的数字格式Kotlin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆