Skip to content

Commit

Permalink
Added GUI for selecting file
Browse files Browse the repository at this point in the history
Added option for selecting multiple files
  • Loading branch information
tapish13031997 committed Apr 8, 2017
1 parent b7b4a1f commit e84b4dd
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 10 deletions.
Binary file added 10.pdf
Binary file not shown.
Binary file added module_linux april part1.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions module_linux/browser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Tkinter,tkFileDialog
def browse():
root = Tkinter.Tk()
root.withdraw()
filez = tkFileDialog.askopenfilenames(parent=root,title='Choose a file',filetypes = (("pdf files","*.pdf"),("all files","*.*")))
return root.tk.splitlist(filez)
Binary file added module_linux/browser.pyc
Binary file not shown.
26 changes: 20 additions & 6 deletions module_linux/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import main
import universal
import browser
import mysql
from shutil import copyfile
universal.init()
mysql.init()
files=browser.browse()
for _file in files :
#main.run_command("cp "+str(_file)+" "+universal.current_dir)
src=str(_file)
universal.filename=""
temp=len(_file)-1
while _file[temp]!="/":
universal.filename=_file[temp]+universal.filename
temp-=1
dst=str(universal.current_dir+'/'+str(universal.filename))
copyfile(src,dst)
universal.logfile=universal.filename #as univeral.filename changes in main
mysql.createconnection()
main.initial()
mysql.closeconnection()
main.run_command("rm "+universal.logfile)
#year=input("year\n")
#s=main.run_command("ls "+str(year),1).split("\n")
#fappend.close()
Expand All @@ -14,9 +34,3 @@
#fappend.write("\n********"+"\n"+str(year)+"\n*************\n\n\n")
#fappend.close()
#i=input("Filename\n")
i=1
while i<=1:
universal.filename=str(i)
universal.logfile=str(i)
main.initial()
i+=1
Binary file modified module_linux/extractor.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions module_linux/logwriter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#filename is set to universal.logfile.txt
import universal
def logwrite(log):
log_file = open(universal.logfile+".txt","a")
Expand Down
Binary file modified module_linux/logwriter.pyc
Binary file not shown.
8 changes: 6 additions & 2 deletions module_linux/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import commands
import excelwriter
import parser
import logwriter
import logwriter
import mysql
from PyPDF2 import PdfFileWriter, PdfFileReader
def burstpdf():
infile = PdfFileReader(open(universal.filename, 'rb'))
Expand Down Expand Up @@ -38,15 +39,18 @@ def initial():
i+=1
if parser.begin()!=-1:
excelwriter.loop()
mysql.loop()
break
universal.flag=1 #Process of extraction will start
print (universal.con)
while i<no_of_pages:
universal.filename=str(i)
convert.convert() #for initializing conversion of files
if parser.begin()==-1:
i+=1
continue
continue
excelwriter.loop()
mysql.loop()
i+=1
universal.workbook.close()
run_command("rm -r "+universal.pdf_folder)
Expand Down
Binary file modified module_linux/main.pyc
Binary file not shown.
93 changes: 93 additions & 0 deletions module_linux/mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import _mysql
import universal
import datetime
#init() function creates connection as soon as it starts and ends the same at the end.
#for using loop() function first create a connection using createconnection and after putting all the data close the connection by executing closeconeection
def createconnection():
try:
universal.con = _mysql.connect(universal.host,universal.user,universal.password)
universal.con.query("use "+ universal.dbname)
except _mysql.Error, e:
print(e)

def closeconnection():
try:
universal.con.close()
except _mysql.Error, e:
print(e)
def transform(tag):
f = "%d/%m/%Y"
s=universal.data[tag]
s=s.lower()
if(bool(s.find('a')!=-1)|bool(s.find('n')!=-1)):
s="01/01/0001"
s=s.replace('.','/').replace('-','/')
ss=datetime.datetime.strptime(s, f)
universal.data[tag]=str(ss.year)+"/"+str(ss.month)+"/"+str(ss.day)
# print(universal.data[tag])
def init():
try:
universal.con = _mysql.connect(universal.host,universal.user,universal.password)
universal.con.query("create database if not exists "+universal.dbname)
universal.con.query("use "+universal.dbname)
universal.con.query("create table if not exists "+universal.tablename+"("+
"Application_No varchar(50),"+
"Date_of_filing_of_Application DATE,"+
"Publication_Date DATE,"+
"Name_of_Applicant varchar(1000),"+
"Title_of_Invention varchar(1000),"+
"Name_of_Inventor varchar(1500),"+
"Abstract varchar(3500),"+
"No_of_Pages varchar(30),"+
"No_of_Claims varchar(30),"+
"International_Classification varchar(50),"+
"Priority_Document_No varchar(50),"+
"Priority_date DATE,"+
"Name_of_Priority_country varchar(30),"+
"International_Publication_No varchar(30),"+
"International_Application_No varchar(30),"+
"International_Application_No_filing_date DATE,"+
"Patent_of_addition_to_Application_No varchar(30),"+
"Patent_of_addition_to_Application_No_filing_date DATE,"+
"Divisional_Application_No varchar(30),"+
"Divisional_Application_No_filing_date DATE"+
")")
except Exception as e:
print (e)
finally:
closeconnection()

def loop():
try:
transform("Date of filing of Application")
transform("Publication Date")
transform("Priority Date")
transform("IAFiling Date")
transform("IBFiling Date")
transform("ICFiling Date")
q = ('insert into '+universal.tablename+' values("'+
str(universal.data["Application No."])+'","'+
str(universal.data["Date of filing of Application"])+'","'+
str(universal.data["Publication Date"])+'","'+
str(universal.data["Name of Applicant"])+'","'+
str(universal.data["Title of the invention"])+'","'+
str(universal.data["Name of Inventor"])+'","'+
str(universal.data["Abstract"])+'","'+
str(universal.data["No. of Pages"])+'","'+
str(universal.data["No. of Claims"])+'","'+
str(universal.data["International classification"])+'","'+
str(universal.data["Priority Document No"])+'","'+
str(universal.data["Priority Date"])+'","'+
str(universal.data["Name of priority country"])+'","'+
str(universal.data["International Publication No"])+'","'+
str(universal.data["International Application No"])+'","'+
str(universal.data["IAFiling Date"])+'","'+
str(universal.data["Patent of Addition to Application Number"])+'","'+
str(universal.data["IBFiling Date"])+'","'+
str(universal.data["Divisional to Application Number"])+'","'+
str(universal.data["ICFiling Date"])+'")')
universal.con.query(q)
#print(q)
except Exception as e:
print(e)

Binary file added module_linux/mysql.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions module_linux/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import datetime
f = "%d/%m/%Y"
s='07.04-2006'
s=s.replace('.','/').replace('-','/')
ss=datetime.datetime.strptime(s, f)
print(str(ss.year)+" "+str(ss.month)+' '+str(ss.day))
16 changes: 14 additions & 2 deletions module_linux/universal.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#file containing global variables
import os
def init():
global tag #records the name of the keys in data dictionary
tag=["Application No.","Date of filing of Application","Publication Date","Name of Applicant","Title of the invention","Name of Inventor","Abstract","No. of Pages","No. of Claims","International classification","Priority Document No","Priority Date","Name of priority country","International Publication No","International Application No","IAFiling Date","Patent of Addition to Application Number","IBFiling Date","Divisional to Application Number","ICFiling Date"]
global dbname
dbname = "patents"
global tablename
tablename = "patent_tables"
global host
host = "localhost"
global user
user = "root"
global password
password = "1killer2"
global data
data={}
global tree
global con
# global test
# test=[]
global datastring
Expand All @@ -22,6 +35,5 @@ def init():
global row #row counter
global flag #Flag for process of extraction has started or not
flag=0
global logfile
global logfile#filename is set to universal.logfile.txt
logfile=""

Binary file modified module_linux/universal.pyc
Binary file not shown.

0 comments on commit e84b4dd

Please sign in to comment.