Example #1
0
def test_import_2015txt():
    path = ur'D:\2014项目\贝叶斯\贝叶斯隐形故障系统状态评价数据(2010-2015)\输电管理所2015年第一次状态评价报告.txt'
    lines = []
    l = []
    with open(path) as f:
        idx = 0
        for line in f.readlines():
            # if idx < 8:
            #     idx += 1
            #     continue
            lines.append(line.strip())
            # idx += 1

    for i in range(0, len(lines), 12):
        o = {}
        # o['index'] = dec(lines[i+1])
        # print(enc1(dec(lines[i+3])))
        o['check_year'] = 2015
        o['line_state'] = dec(lines[i+2]).replace(u'严重',u'IV').replace(u'异常',u'III').replace(u'注意',u'II').replace(u'正常',u'I')
        o['line_name'] = dec(lines[i+3]).replace(u'500kV', '').replace(u'220kV', '').replace(u'110kV', '').replace(u'Ⅰ', 'I').replace(u'Ⅱ', 'II')
        if o['line_name'][-1] == u'回':
            o['line_name'] = o['line_name'].replace(u'回', u'回线')
        o['voltage'] = dec(lines[i+4])
        o['description'] = dec(lines[i+9])
        o['suggestion'] = dec(lines[i+11])
        l.append(o)
        # print(o)
        # if i>100:
        #     break
    print(len(l))
    with codecs.open(path+'.json', 'w', 'utf-8-sig' ) as f:
        f.write(json.dumps(l, ensure_ascii=False, indent=4))
    export_xls(l)
Example #2
0
def modify_config_js():
    path = os.path.join(module_path(), '..', 'data', 'www', 'js', 'config.js')
    l = []
    with open(path) as f:
        for i in f.readlines():
            if len(i.strip())>14 and i.strip()[:14] == 'var g_app_root':
                root = os.path.join(module_path(), '..','data', 'www')
                root = root.replace('\\','/')
                g_app_root = 'var g_app_root = "file:///' + root + '";\r\n'
                l.append(g_app_root)
            elif len(i.strip())>20 and i.strip()[:20] == 'var g_local_tile_url':
                g_local_tile_path = 'var g_local_tile_url = "%s";\r\n' % gConfig['map_local_tiles_url']
                l.append(g_local_tile_path)
            elif "var g_default_basemap" in i:
                if len(gConfig['map_local_tiles_url'])>0:
                    l.append("var g_default_basemap = 'basemap_esrilocal';\r\n")
                else:
                    l.append("var g_default_basemap = 'basemap_googlesat';\r\n")
            elif "'basemap_esrilocal':'本地地图'," in i:
                if len(gConfig['map_local_tiles_url'])>0:
                    l.append("\t'basemap_esrilocal':'本地地图',\r\n")
                else:
                    l.append("\t//'basemap_esrilocal':'本地地图',\r\n")
            else:
                l.append(i)
                
    s = ''
    for i in l:
        s += dec(i) 
    #print(s)
    with open(path, 'w') as f:
        f.write(enc(s))
Example #3
0
def test_import_2015txt():
    path = ur'D:\2014项目\贝叶斯\贝叶斯隐形故障系统状态评价数据(2010-2015)\输电管理所2015年第一次状态评价报告.txt'
    lines = []
    l = []
    with open(path) as f:
        idx = 0
        for line in f.readlines():
            # if idx < 8:
            #     idx += 1
            #     continue
            lines.append(line.strip())
            # idx += 1

    for i in range(0, len(lines), 12):
        o = {}
        # o['index'] = dec(lines[i+1])
        # print(enc1(dec(lines[i+3])))
        o['check_year'] = 2015
        o['line_state'] = dec(lines[i + 2]).replace(u'严重', u'IV').replace(
            u'异常', u'III').replace(u'注意', u'II').replace(u'正常', u'I')
        o['line_name'] = dec(lines[i + 3]).replace(u'500kV', '').replace(
            u'220kV', '').replace(u'110kV',
                                  '').replace(u'Ⅰ', 'I').replace(u'Ⅱ', 'II')
        if o['line_name'][-1] == u'回':
            o['line_name'] = o['line_name'].replace(u'回', u'回线')
        o['voltage'] = dec(lines[i + 4])
        o['description'] = dec(lines[i + 9])
        o['suggestion'] = dec(lines[i + 11])
        l.append(o)
        # print(o)
        # if i>100:
        #     break
    print(len(l))
    with codecs.open(path + '.json', 'w', 'utf-8-sig') as f:
        f.write(json.dumps(l, ensure_ascii=False, indent=4))
    export_xls(l)