Python读取骑行fit文件

故事背景

有一天,我使用wahoo码表骑行记录了一段没有心率带的数据,导出fit文件至电脑。上传至捷安特APP,结果说数据不完整,此时想用代码把心率数据添加到fit文件中。

安装

pip install fitparse

输出有心率和无心率的数据

  • YES.fit 包含心率的数据
  • NO.fit 不包含心率的数据
import fitparse

# Load the FIT file
fitfile = fitparse.FitFile("/Users/houyw/Downloads/YES.fit")

# Iterate over all messages of type "record"
# (other types include "device_info", "file_creator", "event", etc)
for record in fitfile.get_messages("record"):

    # Records can contain multiple pieces of data (ex: timestamp, latitude, longitude, etc)
    for data in record:

        # Print the name and value of the data (and the units if it has any)
        if data.units:
            print(" * {}: {} ({})".format(data.name, data.value, data.units))
        else:
            print(" * {}: {}".format(data.name, data.value))

    print("---")

在这里插入图片描述

在这里插入图片描述

为NO.fit文件增加心率数据并保存

  • 工具:FitCSVTool
  • 逻辑:使用 FitCSVTool 创建的文本文件可以进行编辑,然后使用 FitCSVTool 将其转换回 FIT 文件。
java -jar ./java/FitCSVTool.jar ./examples/activity.fit
java -jar FitCSVTool.jar -c ./activity.csv ./treadmillactivity.fit

参考文献

[1] https://blog.csdn.net/m0_46419189/article/details/123147050
[2] https://developer.garmin.com/fit/fitcsvtool/commandline/
[3] https://developer.garmin.com/fit/example-projects/python/

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值