#!/usr/bin/python # -*- coding:utf-8 _*- """ @author: pengtao @file: check_json.py @time: 2020/03/17 """ import json from typing import Dict, List from create_conf import create_conf_work def get_csv(): with open("1009.csv", "r") as f: data = f.read() csv_data = list() for line in data.split("\n"): tt = dict() if line: tt["serverid"], tt["redis_host"], tt["redis_port"] = line.split() csv_data.append(tt) return csv_data def read_json(filename): json_data = json.loads(open(filename, "r").read()) return json_data def main(): create_conf_work() csv_data = get_csv() for i in range(1, 5): check_file = f"server_list_{i}.json" json_data = read_json(check_file) print(f"check {check_file}") for line in json_data: for csv_line in csv_data: if int(line["serverid"]) == int(csv_line["serverid"]): if line["redis_host"] == csv_line["redis_host"] and int( line["redis_port"] ) == int(csv_line["redis_port"]): pass else: print(line, csv_line, check_file) if __name__ == "__main__": main()