# # /usr/bin/env python
# # -*- coding: UTF-8 -*-l
# import os
# import json
# from actionFile import actionFile
# import matplotlib.pylab as plt
# from matplotlib.pylab import savefig, subplot
# # from test import test
# from pylab import plot, figure, show, subplot
#
# path = "C:\Users\harry-shen\Desktop\\fiveWave\\"
# filenames = os.listdir(path)
# # print filenames
# data = {}
# historys = []
# i=1
# for filename in filenames:
#     a = "_".join(filename.split("_")[1:])
#     if a not in historys:
#         historys.append("_".join(filename.split("_")[1:]))
#         # print(filename.decode('gbk')[:-5])
#
#         with open(path + filename, 'r') as f:
#             try:
#                 data = json.load(f)
#             except:
#                 continue
#             # print(filename)
#
#             # with open("C:\Users\harry-shen\Desktop\\25650.csv",'w') as wf:
#             #
#             #     for each in ['iab','ibc','uab','ubc']:
#             #         d = ''
#             #         for i in range(len(data['data']['iab'])):
#             #             d=d+','+str(data['data'][each][i])
#             #         wf.write(d+'\n')
#             result = actionFile(data['data'], data['ctnum'])
#             # print result
#             # print result[0][0].decode('gbk')
#
#             if result != "nofault":
#                 print(filename.decode('gbk')[:-5])
#                 # print result[0][0].decode('gbk')
#                 figure(1)
#                 if data['ctnum'] == 3:
#                     subplot(211)
#                     plt.plot(data['data']['ia'][:400])
#                     plt.plot(data['data']['ib'][:400])
#                     plt.plot(data['data']['ic'][:400])
#                     subplot(212)
#                     plt.plot(data['data']['ua'][:400])
#                     plt.plot(data['data']['ub'][:400])
#                     plt.plot(data['data']['uc'][:400])
#                     # plt.savefig(str(i) + ".png")
#
#                 else:
#                     subplot(211)
#                     plt.plot(data['data']['iab'][:400])
#                     plt.plot(data['data']['ibc'][:400])
#                     subplot(212)
#                     plt.plot(data['data']['uab'][:400])
#                     plt.plot(data['data']['ubc'][:400])
#                     # plt.savefig(str(i) + ".png")
#                 plt.close()
#     i=i+1