用于计算定时器初值

This commit is contained in:
2024-07-16 00:25:13 +08:00
parent c5e448b3a6
commit 6ce65791ab
4 changed files with 517 additions and 0 deletions

23
other/csv2json.py Normal file
View File

@@ -0,0 +1,23 @@
#coding=utf-8
import csv
import json
# 文件路径
file_path = 'note_data.txt'
# 读取文件并转换为 JSON
notes_dict = {}
with open(file_path, mode='r', encoding='utf-8') as file:
reader = csv.DictReader(file, delimiter='\t')
for row in reader:
note, frequency, wave_length = row['note'], row['frequency'], row['wave_length']
notes_dict[note] = {'frequency': float(frequency), 'wave_length': float(wave_length)}
# 将数据转换为 JSON 并打印
json_data = json.dumps(notes_dict, indent=4)
print(json_data)
# 写入 JSON 文件
with open('note_data.json', 'w', encoding='utf-8') as json_file:
json_file.write(json_data)