Last active
August 5, 2019 02:49
-
-
Save dmattia/48b98c10702995fc7ba588358c5687c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Prereq: pip install --user pandas xlrd | |
Usage: | |
1) Create accounts.xlsx file | |
2) Run 'python accounts.py' | |
""" | |
import pandas as pd | |
import json | |
CLIENT_CONFIG_FIELDS = [ | |
"LowCpuMode", | |
"SuperLowCpuMode", | |
"EngineTickDelay", | |
"DisableModelRendering", | |
"DisableSceneRendering", | |
] | |
CLIENT_FIELDS = [ | |
"RsUsername", | |
"RsPassword", | |
"World", | |
"ScriptName", | |
"IsRepoScript", | |
"ScriptArgs", | |
"UseProxy", | |
"ProxyName", | |
] | |
def create_client(record): | |
""" Takes a dict representing a single row in the excel sheet and returns a dict representing a | |
'Client' value in the output json. | |
""" | |
client = {field: record.get(field, "") for field in CLIENT_FIELDS} | |
client["Config"] = {field: record.get(field, "") for field in CLIENT_CONFIG_FIELDS} | |
return client | |
def main(): | |
""" Reads in the excel file named 'accounts.xlsx' and outputs a file named 'output.json' | |
""" | |
rows = pd.read_excel("accounts.xlsx").fillna("").to_dict(orient='records') | |
config = map(create_client, rows) | |
with open("output.json", "w") as out_file: | |
json.dump(config, out_file, indent=4, sort_keys=True) | |
if __name__ == "__main__": | |
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RsUsername,RsPassword,World,ScriptName,IsRepoScript,ScriptArgs,UseProxy,ProxyPort,ProxyName,ProxyUser,ProxyPass,LowCpuMode,SuperLowCpuMode,EngineTickDelay,DisableModelRendering,DisableSceneRendering | |
MadDev123,rips,82,Manly Chopper,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
1,rips,82,script 1,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
2,rips,82,script 2,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
3,rips,82,script 3,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
4,rips,82,script 4,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
5,rips,82,script 5,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
6,rips,82,script 6,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALSE | |
7,rips,82,script 7,TRUE,-tree yew,FALSE,83,,MadDev,FakePass,TRUE,TRUE,0,FALSE,FALS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yes king!