Skip to content

Commit b2fa621

Browse files
committed
updates DataTool
1 parent 1b7cc3c commit b2fa621

4 files changed

Lines changed: 96 additions & 21 deletions

File tree

Files/DataTool.py

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,31 @@ def addFunctionToData(row):
8282
res += 'male/'
8383
return res.strip("/")
8484

85-
def parseData(file_name="input.xlsx"):
86-
input_df = pd.read_excel(file_name)
85+
def parseData(file_name="input.csv"):
86+
try:
87+
print("Trying to Read file: " + file_name)
88+
if file_name.endswith('.csv'):
89+
input_df = pd.read_csv(file_name)
90+
else:
91+
input_df = pd.read_excel(file_name)
92+
print("Success!")
93+
logging.info("Success!")
94+
except:
95+
print("Cannot Read file: " + file_name)
96+
logging.info("Cannot Read file: " + file_name)
97+
98+
try:
99+
print("Try reading input.csv")
100+
logging.info("Try reading input.csv")
101+
input_df = pd.read_csv("input.csv")
102+
print("Success!")
103+
logging.info("Success!")
104+
except Exception as e:
105+
logging.error('Error at %s', 'division', exc_info=e)
106+
107+
108+
print("Parsing the file...")
109+
logging.info("Parsing the file...")
87110

88111
input_df["name_length"] = input_df.iloc[:,6].apply(lambda x: len(x))
89112

@@ -128,29 +151,41 @@ def parseData(file_name="input.xlsx"):
128151

129152
return df, avg_df
130153

131-
try:
132-
print("Parsing the input.xlsx file...")
133-
logging.info("Parsing the input.xlsx file...")
134-
df, avg_df = parseData()
135-
print("Success!")
136-
logging.info("Success!")
137-
except Exception as e:
138-
logging.error('Error at %s', 'division', exc_info=e)
154+
def readInput():
155+
res = input("""
156+
Please enter your file name
157+
press enter directly to read input.csv
158+
(e.g. input.csv , Class1.xlsx)
159+
""")
160+
if res == "":
161+
res = "input.csv"
162+
return res
139163

140164
try:
141-
print("Saving vehicleGroupData.csv file...")
142-
logging.info("Saving vehicleGroupData.csv file...")
143-
df.to_csv('vehicleGroupData.csv', sep=',', encoding='utf-8', index=False, header=False)
165+
res = readInput()
166+
df, avg_df = parseData(res)
144167
print("Success!")
145168
logging.info("Success!")
146-
except Exception as e:
147-
logging.error('Error at %s', 'division', exc_info=e)
148169

149-
try:
150-
print("Saving AvgAnalysis.csv file...")
151-
logging.info("Saving AvgAnalysis.csv file...")
152-
avg_df.iloc[0:1,:].to_csv('AvgAnalysis.csv', sep=',', encoding='utf-8', index=False, header=True)
153-
print("Success!")
154-
logging.info("Success!")
170+
try:
171+
print("Saving vehicleGroupData.csv file...")
172+
logging.info("Saving vehicleGroupData.csv file...")
173+
df.to_csv('vehicleGroupData.csv', sep=',', encoding='utf-8', index=False, header=False)
174+
print("Success!")
175+
logging.info("Success!")
176+
except Exception as e:
177+
logging.error('Error at %s', 'division', exc_info=e)
178+
179+
try:
180+
print("Saving AvgAnalysis.csv file...")
181+
logging.info("Saving AvgAnalysis.csv file...")
182+
avg_df.iloc[0:1,:].to_csv('AvgAnalysis.csv', sep=',', encoding='utf-8', index=False, header=True)
183+
print("Success!")
184+
logging.info("Success!")
185+
except Exception as e:
186+
logging.error('Error at %s', 'division', exc_info=e)
187+
155188
except Exception as e:
156189
logging.error('Error at %s', 'division', exc_info=e)
190+
191+

Files/dist/DataTool-v1.exe

87.7 MB
Binary file not shown.

Files/dist/READ_ME.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#################### Jadyn Wu ##################
2+
Thank you for downloading Jadyn Wu's Program
3+
I hope you find them useful in your projects
4+
If you have any questions, find my contact in
5+
my personal website below
6+
Cheers!
7+
JadynWu.com
8+
--------------------------------------------------
9+
Personal Website: https://jadynwu.com/
10+
GitHub: https://github.com/YuudachiXMMY
11+
################################################
12+
13+
################# Program Specification ##############
14+
Input file:
15+
- input.csv
16+
17+
output files:
18+
- vehicleGroupData.csv : used for game program
19+
- AvgAnalysis.csv : analysis the average information of some data
20+
21+
22+
Before RUNNING, please ensrue that:
23+
1. The input file is renamed to input.csv
24+
2. DataTool.exe and input.csv are in the SAME folder/directory
25+
26+
27+
To RUN:
28+
1. Double-Click the DataTool.exe
29+
30+
31+
Data format of input.csv:
32+
- Names must be in column G
33+
- Colors must be in column H
34+
- Number of Team Members must be in column I
35+
- Facial Recognition must be in column K
36+
- Glassess must be in column L
37+
- Languages must be in column M
38+
- Number of People identifying themselve as Male must be in column N
39+
- Password must be in column O
40+
- Distance must be in column P

0 commit comments

Comments
 (0)