Skip to content

Commit 1b7cc3c

Browse files
committed
add python automated data parsing toll in Files/PyDataTool
1 parent 86191c1 commit 1b7cc3c

38 files changed

Lines changed: 672 additions & 57 deletions
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: 3
11+
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12+
m_Parent: {fileID: 0}
13+
m_ModifiedSerializedProperties: 0
14+
m_ValidKeywords:
15+
- _EMISSION
16+
m_InvalidKeywords: []
17+
m_LightmapFlags: 1
18+
m_EnableInstancingVariants: 0
19+
m_DoubleSidedGI: 0
20+
m_CustomRenderQueue: -1
21+
stringTagMap: {}
22+
disabledShaderPasses: []
23+
m_LockedProperties:
24+
m_SavedProperties:
25+
serializedVersion: 3
26+
m_TexEnvs:
27+
- _BumpMap:
28+
m_Texture: {fileID: 0}
29+
m_Scale: {x: 1, y: 1}
30+
m_Offset: {x: 0, y: 0}
31+
- _DetailAlbedoMap:
32+
m_Texture: {fileID: 0}
33+
m_Scale: {x: 1, y: 1}
34+
m_Offset: {x: 0, y: 0}
35+
- _DetailMask:
36+
m_Texture: {fileID: 0}
37+
m_Scale: {x: 1, y: 1}
38+
m_Offset: {x: 0, y: 0}
39+
- _DetailNormalMap:
40+
m_Texture: {fileID: 0}
41+
m_Scale: {x: 1, y: 1}
42+
m_Offset: {x: 0, y: 0}
43+
- _EmissionMap:
44+
m_Texture: {fileID: 0}
45+
m_Scale: {x: 1, y: 1}
46+
m_Offset: {x: 0, y: 0}
47+
- _MainTex:
48+
m_Texture: {fileID: 0}
49+
m_Scale: {x: 1, y: 1}
50+
m_Offset: {x: 0, y: 0}
51+
- _MetallicGlossMap:
52+
m_Texture: {fileID: 0}
53+
m_Scale: {x: 1, y: 1}
54+
m_Offset: {x: 0, y: 0}
55+
- _OcclusionMap:
56+
m_Texture: {fileID: 0}
57+
m_Scale: {x: 1, y: 1}
58+
m_Offset: {x: 0, y: 0}
59+
- _ParallaxMap:
60+
m_Texture: {fileID: 0}
61+
m_Scale: {x: 1, y: 1}
62+
m_Offset: {x: 0, y: 0}
63+
m_Ints: []
64+
m_Floats:
65+
- _BumpScale: 1
66+
- _Cutoff: 0.5
67+
- _DetailNormalMapScale: 1
68+
- _DstBlend: 0
69+
- _GlossMapScale: 1
70+
- _Glossiness: 0.84
71+
- _GlossyReflections: 1
72+
- _Metallic: 0.6
73+
- _Mode: 0
74+
- _OcclusionStrength: 1
75+
- _Parallax: 0.02
76+
- _SmoothnessTextureChannel: 0
77+
- _SpecularHighlights: 1
78+
- _SrcBlend: 1
79+
- _UVSec: 0
80+
- _ZWrite: 1
81+
m_Colors:
82+
- _Color: {r: 1, g: 0.43448272, b: 0, a: 1}
83+
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
84+
m_BuildTextureStacks: []

Assets/CarsAssetPack/Models/FBX/3.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/CarsAssetPack/Models/FBX/Car-1.fbx.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Game Manager/LoadCharacter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void Start()
4343
}
4444
var columns = lines.Split(",");
4545
string characterName = columns[0].ToString();
46-
int selectedCharacter = int.Parse(columns[1]) - 1;
46+
int selectedCharacter = int.Parse(columns[1]);
4747
string[] funcList = columns[2].Split("/").Select(func => func.Trim().ToLower()).ToArray();
4848
initializePlayer(characterPrefabs[selectedCharacter], characterName, funcList);
4949
}

Files/DataTool.py

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
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+
import os, logging
13+
import numpy as np
14+
import pandas as pd
15+
import csv
16+
17+
logging.basicConfig(filename="logs.log", filemode="w", level=logging.DEBUG)
18+
19+
info = """
20+
#################### Jadyn Wu ##################
21+
Thank you for downloading Jadyn Wu's Program
22+
I hope you find them useful in your projects
23+
If you have any questions, find my contact in
24+
my personal website below
25+
Cheers!
26+
JadynWu.com
27+
--------------------------------------------------
28+
Personal Website: https://jadynwu.com/
29+
GitHub: https://github.com/YuudachiXMMY
30+
################################################
31+
"""
32+
print(info)
33+
logging.info(info)
34+
35+
directory = os.path.abspath(os.path.join(os.path.curdir))
36+
37+
print("Current Working Directory: " + directory)
38+
logging.info("Current Working Directory: " + directory)
39+
40+
#check if dir exist if not create it
41+
def check_dir(file_name):
42+
directory = os.path.dirname(file_name)
43+
if not os.path.exists(directory):
44+
os.makedirs(directory)
45+
print(directory)
46+
47+
def column_index(df, query_cols):
48+
cols = df.columns.values
49+
sidx = np.argsort(cols)
50+
return sidx[np.searchsorted(cols,query_cols,sorter=sidx)]
51+
52+
def transformToGameData():
53+
output_file = directory+'//vehicleGroupData.csv'
54+
check_dir(output_file)
55+
with open(output_file, 'w', newline='') as file:
56+
writer = csv.writer(file)
57+
58+
writer.writerow(["SN", "Movie", "Protagonist"])
59+
60+
car_color_dict = {
61+
"green" : 0,
62+
"orange" : 0,
63+
"black" : 1,
64+
"red" : 2,
65+
"blue" : 3,
66+
"white" : 4
67+
}
68+
69+
def addFunctionToData(row):
70+
res = ''
71+
if row["facial_tag"]:
72+
res += 'facerecog/'
73+
if row["glasses_tag"]:
74+
res += 'glasses/'
75+
if row["language_tag"]:
76+
res += 'language/'
77+
if row["pwd_tag"]:
78+
res += 'password/'
79+
if row["distance_tag"]:
80+
res += 'distance/'
81+
if row["male_tag"]:
82+
res += 'male/'
83+
return res.strip("/")
84+
85+
def parseData(file_name="input.xlsx"):
86+
input_df = pd.read_excel(file_name)
87+
88+
input_df["name_length"] = input_df.iloc[:,6].apply(lambda x: len(x))
89+
90+
# Cleaning for Data Analysis
91+
input_df["avg_facial"] = input_df.iloc[:,10].mean()
92+
93+
input_df["avg_glasses"] = input_df.iloc[:,11].mean()
94+
95+
input_df["avg_language"] = input_df.iloc[:,12].mean()
96+
97+
input_df["avg_pwd"] = input_df.iloc[:,14].mean()
98+
99+
input_df["avg_distance"] = input_df.iloc[:,15].mean()
100+
101+
input_df["avg_nameLength"] = input_df["name_length"].mean()
102+
103+
# Analysis DF
104+
avg_df = input_df[["avg_nameLength", "avg_facial", "avg_glasses", "avg_language", "avg_pwd", "avg_distance"]]
105+
106+
avg_df = avg_df.round(0)
107+
108+
# Cleaning for Game df
109+
input_df["facial_tag"] = input_df["avg_facial"] <= input_df.iloc[:,10]
110+
111+
input_df["glasses_tag"] = input_df["avg_glasses"] <= input_df.iloc[:,11]
112+
113+
input_df["language_tag"] = input_df["avg_language"] <= input_df.iloc[:,12]
114+
115+
input_df["pwd_tag"] = input_df["avg_pwd"] >= input_df.iloc[:,14]
116+
117+
input_df["distance_tag"] = input_df["avg_distance"] <= input_df.iloc[:,15]
118+
119+
input_df["male_tag"] = input_df.iloc[:,13].apply(lambda x: True if x>2 else False)
120+
121+
input_df['functions'] = input_df.apply(addFunctionToData, axis=1)
122+
123+
# Game df
124+
df = input_df.iloc[:, [6,7, column_index(input_df, ['functions'])[0]]]
125+
df.columns = ['name', 'vehicle', 'functions']
126+
127+
df.iloc[:,1] = df.iloc[:,1].apply(lambda x: car_color_dict[x.lower()])
128+
129+
return df, avg_df
130+
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)
139+
140+
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)
144+
print("Success!")
145+
logging.info("Success!")
146+
except Exception as e:
147+
logging.error('Error at %s', 'division', exc_info=e)
148+
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!")
155+
except Exception as e:
156+
logging.error('Error at %s', 'division', exc_info=e)

Files/DataTool.spec

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['DataTool.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=[],
14+
noarchive=False,
15+
optimize=0,
16+
)
17+
pyz = PYZ(a.pure)
18+
19+
exe = EXE(
20+
pyz,
21+
a.scripts,
22+
a.binaries,
23+
a.datas,
24+
[],
25+
name='DataTool',
26+
debug=False,
27+
bootloader_ignore_signals=False,
28+
strip=False,
29+
upx=True,
30+
upx_exclude=[],
31+
runtime_tmpdir=None,
32+
console=True,
33+
disable_windowed_traceback=False,
34+
argv_emulation=False,
35+
target_arch=None,
36+
codesign_identity=None,
37+
entitlements_file=None,
38+
icon=['jw.ico'],
39+
)

Files/PyDataTool/DataTool.exe

87.7 MB
Binary file not shown.

Files/PyDataTool/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.xlsx
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.xlsx
24+
2. DataTool.exe and input.xlsx 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.xlsx:
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

Files/dist/DataTool.exe

87.7 MB
Binary file not shown.

Files/jw.ico

24.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)