我有点迷恋python逻辑。
我想就如何处理python遇到的问题和解析数据的方法提出一些建议。在
我花了一点时间阅读python参考文档并浏览了这个站点,我知道有几种方法可以实现我想要实现的目标,这就是我所走的道路。
我正在用一些卫星硬件生成的数据重新格式化一些文本文件,然后上传到MySQL数据库中。在
这是原始数据
TP N: 1
Frequency: 12288.635 Mhz
Symbol rate: 3000 KS
Polarization: Vertical
Spectrum: Inverted
Standard/Modulation: DVB-S2/QPSK
FEC: 1/2
RollOff: 0.20
Pilot: on
Coding mode: ACM/VCM
Short frame
Transport stream
Single input stream
RF-Level: -49 dBm
Signal/Noise: 6.3 dB
Carrier width: 3.600 Mhz
BitRate: 2.967 Mbit/s
对卫星上的每个转发器TP N
重复上述部分
我用这个脚本提取我需要的数据
然后,在将输出数据发送到数据库之前,输出数据的格式如下所示
12288.635 Mhz
3000 KS
Vertical
DVB-S2/QPSK
1/2
-49 dBm
6.3 dB
3.600 Mhz
2.967 Mbit/s
这个脚本运行得很好,但是对于一些我想在MySQL上实现的特性,我需要进一步编辑它。在
KS
,dBm
,dB
,Mhz
,Mbit
。在我不确定是否要继续沿着这条路径添加到现有的脚本中(我在输出文件写入的地方卡住了)。或者重新考虑我处理原始文件的方式。在
我的解决方案是粗糙的,可能不适用于角落案件,但这是一个良好的开端。在
讨论
value = int(...)
的行中,我们试图将字符串值转换为整数,从而删除点和后面的数字。在在
files
列表中添加所有要分析的文件。它将把每个文件的输出写成一行,每个字段用逗号隔开。在相关问题 更多 >
编程相关推荐