Skip to content

Commit

Permalink
Fully working example
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximShepelev committed Oct 24, 2018
1 parent 6abfac0 commit 8fe4491
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 77 deletions.
94 changes: 52 additions & 42 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions json/parse.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/python
import json
import openpyxl
import time
from datetime import datetime
from tkinter import *
from tkinter import Tk, Label, Button, Entry, StringVar, W, E, filedialog
from tkinter.ttk import *


# Input Token and Choose File
Expand All @@ -16,11 +18,9 @@ def __init__(self, master):
self.token = "a640cea90e04722ac2fb989023122b74"
self.filepath = StringVar()

self.total_label_text = IntVar()

self.labelT = Label(master, text="Token:")
self.entry1 = Entry(master, textvariable=self.token) #, validate="key", validatecommand=(vcmd, '%P'))

self.entry2 = Entry(master)
self.labelF = Label(master, text="File Path:")

Expand Down Expand Up @@ -58,21 +58,23 @@ def get_toke(self):
def choose(self):
self.filepath = filedialog.askopenfilename()


# Running GUI input
root = Tk()
my_gui = File_Token_Chooser(root)
root.mainloop()

print("Token entered" + my_gui.get_toke())
print("Using builtin getter, filepath: " + my_gui.entry2.get())
print("Using improvised getter: " + my_gui.get_filepath())
print("Starting cell: " + my_gui.end_cell.get())
print("End cell: " + my_gui.start_cell.get())

# Getting Data from GUI input
# print("Token entered" + my_gui.get_toke())
# print("Using builtin getter, filepath: " + my_gui.entry2.get())
# print("Using improvised getter: " + my_gui.get_filepath())
token = my_gui.get_toke()
filepath = my_gui.get_filepath()
start_cell = my_gui.start_cell.get()
end_cell = my_gui.end_cell.get()



# Output
# Output to Excel Class
def output_to_excel():
now = datetime.now()
output_file = 'results_' + now.strftime("%Y-%m-%d_%H:%M:%S") + '.xlsx'
Expand Down Expand Up @@ -100,11 +102,13 @@ def output_to_excel():

wb.save(output_file)

# Open example JSON file
file = open("json.example","r")
#print(file.read())

# Parse example JSON file
jsondata = json.loads(file.read())


# Test. Outputting to Console data from JSON
domains = ""
for item in jsondata['result']['top']:
domains += item.get("domain") + ","
Expand All @@ -125,6 +129,11 @@ def output_to_excel():
print(status_msg)


# Write Data to Excel File
# output_to_excel()

# Output
# output_to_excel()
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, "Done")
mainloop()
Loading

0 comments on commit 8fe4491

Please sign in to comment.