Python读取设备节点存入CSV

import csv
import os
import time


if __name__ == '__main__':
    f = open("result.csv", 'w',encoding='utf-8-sig',newline='' "")
    csv_writer = csv.writer(f)
    csv_writer.writerow(["get_voltage_now","get_input_current_now","get_voltage_now","get_current_now","get_capacity","get_temp","get_resistance_id","get_charge_type","get_real_type","get_charge_full","get_esr_actual"])
    row_count = 1
    while 1:
        list_onerow = []
        # 先判断是否开机
        os.system("adb wait-for-usb-device")
        r = os.popen("adb shell source /data/test.sh")
        list_onerow = [r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),r.readline().replace("\n",""),]
        # 追加到CSV
        if list_onerow[0] != '':
            csv_writer.writerow(list_onerow)
            print(row_count)
            row_count+=1
        # time.sleep(1)

test.sh

cat /sys/class/power_supply/usb/voltage_now
cat /sys/class/power_supply/usb/input_current_now
cat /sys/class/power_supply/battery/voltage_now
cat /sys/class/power_supply/battery/current_now
cat /sys/class/power_supply/battery/capacity
cat /sys/class/power_supply/battery/temp
cat /sys/class/power_supply/bms/resistance_id
cat /sys/class/power_supply/battery/charge_type
cat /sys/class/power_supply/usb/real_type
cat /sys/class/power_supply/bms/charge_full
cat /sys/class/power_supply/bms/esr_actual

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

u影动

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值