加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
csv2zvms(full).py 567 Bytes
一键复制 编辑 原始数据 按行查看 历史
朱程炀 提交于 2021-10-10 20:55 . upd scripts
import json
def loadFromFile(fnm):
with open(fnm) as f:
return f.read()
def writeToFile(fnm, content):
with open(fnm, "w") as f:
f.write(content)
def loadCSV(a):
ret = []
for i in a.split():
tmp = []
for j in i.split(","):
tmp += [j]
ret += [tmp[:]]
return ret
tableList = ["user", "student", "volunteer", "stu_vol", "class_vol"]
r = {}
for i in tableList:
r[i] = loadCSV(loadFromFile(input("Please input csvName of %s: " % i)))
writeToFile(input("Output filename: "), json.dumps(r))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化