#!/usr/bin/python
# coding=gbk
import sys, os, datetime,glob,csv
from zt import Ui_MainWindow
from PyQt5.QtWidgets import QApplication, QMainWindow,QTableWidget,QTableWidgetItem,QHeaderView
import matplotlib.pyplot as plt
from pylab import *
#from sqlalchemy import create_engine
# import tab
# from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import QtWidgets, QtCore, QtGui
# from PyQt5 import QtCore, QtGui, QtWidgets
class win(QMainWindow, Ui_MainWindow): ##QMainWindow要导入,Ui_MainWindow对应jk.ui的类名
def __init__(self):
super(win, self).__init__()
self.setupUi(self)
self.pushButton.clicked.connect(self.on_click_1)
self.pushButton_2.clicked.connect(self.on_click_2)
#if self.radioButton.isChecked():
#elif self.radioButton_2.isChecked():
def on_click_1(self):
import win32com.client, os
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
# find_file = filedialog.askdirectory(title="请选择要查找的文件夹") # 获得选择好的文件夹
Files_r = filedialog.askopenfilename(title="请选择要筛选的EXCEL表", filetypes=[('EXCEL文件', '*.xlsx')]) # 获得选择好的文件
if not Files_r:
print("没有选EXCEL表!")
else:
cnn = win32com.client.Dispatch(r'ADODB.connection')
rs = win32com.client.Dispatch(r'ADODB.Recordset')
# cnn.Open ("Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source ="+os.getcwd()+"\\")
cnn.Open("provider=microsoft.ace.oledb.12.0;Extended Properties =excel 12.0;data source=" + Files_r)
# print("Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source ="+os.getcwd()+"\\")
sql = "select a.ENBFunctionTDD,a.description,a.refEUtranCellTDD,B.ENBFunctionTDD,B.description from [EUtranRelationTDD$] a,[EUtranCellTDD$] B where a.refEUtranCellTDD <>'' and VAL(a.ENBFunctionTDD)>1 and a.refEUtranCellTDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./同频.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./同频.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
# cnn.Close()
rs.Close()
print("同频 exetue is done!")
sql1 = "select a.ENBFunctionTDD,a.description,a.refExternalEUtranTCellTDD,B.eNBId,B.cellLocalId from [EUtranRelationTDD$] a,[ExternalEUtranTCellTDD$] B where a.refExternalEUtranTCellTDD <>'' and VAL(a.ENBFunctionTDD)>1 and a.refExternalEUtranTCellTDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql1, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./TDD.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./TDD.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
rs.Close()
print("TDD exetue is done!")
sql2 = "select a.ENBFunctionTDD,a.description,a.refExternalEUtranTCellFDD,B.eNBId,B.cellLocalId from [EUtranRelationTDD$] a,[ExternalEUtranTCellFDD$] B where a.refExternalEUtranTCellFDD <>'' and VAL(a.ENBFunctionTDD)>1 and a.refExternalEUtranTCellFDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql2, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./FDD.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./FDD.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
rs.Close()
print("FDD exetue is done!")
def on_click_2(self):
import win32com.client, os
import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
# find_file = filedialog.askdirectory(title="请选择要查找的文件夹") # 获得选择好的文件夹
Files_r = filedialog.askopenfilename(title="请选择要筛选的EXCEL表", filetypes=[('EXCEL文件', '*.xlsx')]) # 获得选择好的文件
if not Files_r:
print("没有选EXCEL表!")
else:
cnn = win32com.client.Dispatch(r'ADODB.connection')
rs = win32com.client.Dispatch(r'ADODB.Recordset')
# cnn.Open ("Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source ="+os.getcwd()+"\\")
cnn.Open("provider=microsoft.ace.oledb.12.0;Extended Properties =excel 12.0;data source=" + Files_r)
# print("Provider = Microsoft.ace.Oledb.12.0;Extended Properties =TEXT;Data Source ="+os.getcwd()+"\\")
sql = "select a.ENBFunctionFDD,a.description,a.refEUtranCellFDD,B.ENBFunctionFDD,B.description from [EUtranRelation$] a,[EUtranCellFDD$] B where a.refEUtranCellFDD <>'' and VAL(a.ENBFunctionFDD)>1 and a.refEUtranCellFDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./FDD同频.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./FDD同频.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
# cnn.Close()
rs.Close()
print("FDD同频 exetue is done!")
sql1 = "select a.ENBFunctionFDD,a.description,a.refExternalEUtranCellTDD,B.eNBId,B.cellLocalId from [EUtranRelation$] a,[ExternalEUtranCellTDD$] B where a.refExternalEUtranCellTDD <>'' and VAL(a.ENBFunctionFDD)>1 and a.refExternalEUtranCellTDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql1, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./FDD_TDD.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./FDD_TDD.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
rs.Close()
print("FDD_TDD exetue is done!")
sql2 = "select a.ENBFunctionFDD,a.description,a.refExternalEUtranCellFDD,B.eNBId,B.cellLocalId from [EUtranRelation$] a,[ExternalEUtranCellFDD$] B where a.refExternalEUtranCellFDD <>'' and VAL(a.ENBFunctionFDD)>1 and a.refExternalEUtranCellFDD=b.MOI"
# s = cnn.Execute(sql)
rs.Open(sql2, cnn, 1, 3)
# print(rs.Fields.count)
# print(rs.RecordCount)
if rs.RecordCount == 0:
sys.exit()
else:
with open('./FDD_FDD.csv', 'w', encoding='GBK') as out_f:
for i in range(0, rs.Fields.count):
out_f.write(rs.Fields(i).Name + chr(44))
out_f.write('\n')
out_f.closed
with open('./FDD_FDD.csv', 'a', encoding='GBK') as out_f:
rs.MoveFirst()
num = 1
while not rs.EOF:
for j in range(0, rs.Fields.count):
out_f.write(chr(34) + str(rs.Fields.Item(j).Value) + chr(34) + chr(44))
out_f.write('\n')
rs.MoveNext()
rs.Close()
print("FDD_FDD exetue is done!")
if __name__ == '__main__':
#QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QApplication(sys.argv)
# MainWindow = QMainWindow()
w = win()
w.show()
# ui = Ui_MainWindow()
# ui.setupUi(MainWindow)
# MainWindow.show()
sys.exit(app.exec_())