@@ -77,25 +77,16 @@ _json = carball.decompile_replay('9EB5E5814D73F55B51A1BD9664D4CBF3.replay',
7777Analyze a JSON game object:
7878``` Python
7979import carball
80- import os
8180import gzip
8281from carball.json_parser.game import Game
8382from carball.analysis.analysis_manager import AnalysisManager
83+
8484# _json is a JSON game object (from decompile_replay)
8585game = Game()
8686game.initialize(loaded_json = _json)
8787
8888analysis_manager = AnalysisManager(game)
8989analysis_manager.create_analysis()
90-
91- # write proto out to a file
92- # read api/*.proto for info on the object properties
93- with open (os.path.join(' output.pts' ), ' wb' ) as fo:
94- analysis_manager.write_proto_out_to_file(fo)
95-
96- # write pandas dataframe out as a gzipped numpy array
97- with gzip.open(os.path.join(' output.gzip' ), ' wb' ) as fo:
98- analysis_manager.write_pandas_out_to_file(fo)
9990
10091# return the proto object in python
10192proto_object = analysis_manager.get_protobuf_data()
@@ -107,6 +98,35 @@ json_oject = analysis_manager.get_json_data()
10798dataframe = analysis_manager.get_data_frame()
10899```
109100
101+ You may want to save carball analysis results for later use:
102+
103+ ``` python
104+ # write proto out to a file
105+ # read api/*.proto for info on the object properties
106+ with open (' output.pts' , ' wb' ) as fo:
107+ analysis_manager.write_proto_out_to_file(fo)
108+
109+ # write pandas dataframe out as a gzipped numpy array
110+ with gzip.open(' output.gzip' , ' wb' ) as fo:
111+ analysis_manager.write_pandas_out_to_file(fo)
112+ ```
113+
114+ Read the saved analysis files:
115+
116+ ``` python
117+ import gzip
118+ from carball.analysis.utils.pandas_manager import PandasManager
119+ from carball.analysis.utils.proto_manager import ProtobufManager
120+
121+ # read proto from file
122+ with open (' output.pts' , ' rb' ) as f:
123+ proto_object = ProtobufManager.read_proto_out_from_file(f)
124+
125+ # read pandas dataframe from gzipped numpy array file
126+ with gzip.open(' output.gzip' , ' rb' ) as f:
127+ dataframe = PandasManager.read_numpy_from_memory(f)
128+ ```
129+
110130### Command Line
111131
112132Carball comes with a command line tool to analyze replays. To use carball from the command line:
0 commit comments