我有一个格式为
的文本文件rule {
source: 1
target: 1
target_code: 1
}
rule {
source: 2
target: 9
target_code: 3
}
我在下面编写了一个代码来读取文本文件,但无法转换为csv行,例如
source, target, target code
1,1,1
2,9,3
需要指导
# Open a file: file
file = open('routing_rules.txt',mode='r')
# read all lines at once
txt = file.read()
print(txt)
# close the file
file.close()