用csv单元格中的数字修改json字段

时间:2019-07-03 18:21:51

标签: python json python-2.7 csv

我想将json文件链接到CSV文件:的确,我在程序的出口处有一个字典,该字典是我在CSV文件中编写的,如下所示: enter image description here

我想通过csv文件的字段更新json文件的数据。 (实际上,一行中获得的框对应于我的json文件的字段。)我的csv文件的每一行都是新的一年的新迭代,因此有必要使用与以下内容相对应的值来更新json文件:新的一年。到目前为止,我是手动进行的,并且希望成功实现自动化。有人可以指导我吗?我不知道我是否足够清楚,如果您需要更多信息,请不要犹豫

{
"idDataCenter": "datacenter",
"batterySources": [
{"idSource": "batt1", "model": "v1", "techno": "techno", "nbItems": 1, "sourceState": ["SOURCE_ON"],    "curve": "nice curve", "capacity": 6140, "maxCurrent": 500, "ratedVoltage": 1300, "maxChargePower": 1060, "maxDischargePower": 1060, "sigma": 0, "maxProduction": 0},
{"idSource": "batt2", "model": "v2", "techno": "techno", "nbItems": 0, "sourceState": ["SOURCE_ON"],    "curve": "cool curve", "capacity": 7000, "maxCurrent": 500, "ratedVoltage": 6000, "maxChargePower": 800, "maxDischargePower": 800, "sigma": 0, "maxProduction": 0}
],
"photoVoltaicSources": [
{"idSource": "pv1", "model": "v1", "techno": "t", "nbItems": 1, "sourceState": ["SOURCE_ON"], "curve": "nice curve", "panelArea": 1, "numberOfPanels": 9000, "efficiencyCurve": "super efficient" },
{"idSource": "pv2", "model": "v1", "techno": "t", "nbItems": 1, "sourceState": ["SOURCE_ON"], "curve": "nice curve", "panelArea": 1, "numberOfPanels": 130, "efficiencyCurve": "super efficient" }
],
"windSources": [
{"idSource": "wind1", "nbItems": 1, "model": "v1", "techno": "10", "sourceState": ["SOURCE_ON"], "height": 25, "curve": "nice", "minSpeed": 4, "maxSpeed":  30, "ratedSpeed": 10, "maxProduction": 400},
{"idSource": "wind2", "nbItems": 0, "model": "v2", "techno": "10", "sourceState": ["SOURCE_OFF"], "height": 25, "curve": "alright", "minSpeed": 4, "maxSpeed":  30, "ratedSpeed": 10, "maxProduction": 400}
],
"gridSources": [{"idSource": "grid1", "model": "v1", "techno": "techno", "nbItems": 1, "sourceState": ["SOURCE_ON"],    "curve": "nice curve", "capacity": 1, "maxProduction": 0 }],
"fuelCellSources": [
{"idSource": "fc1", "model": "v1", "techno": "techno", "nbItems": 1, "sourceState": ["SOURCE_ON"],    "curve": "nice curve", "H2OConsumptionRate": 3, "maxProduction": 840, "minProduction": 0 }
],
"superCapacitorSources": [],
"electrolyzerSources": [
{"idSource": "ez1", "model": "v1", "techno": "techno", "nbItems": 1, "sourceState": ["SOURCE_ON"],    "curve": "nice curve", "minProduction": 150, "maxProduction": 832.65, "tankSize": 8600,
"h2Schedule":  {"startTime":  0, "byStep": 86400000, "data": [600, 580, 200, 610, 500, 550, 570, 400]}}
]

} enter code here

0 个答案:

没有答案