I'm working with a map of which is split up into 750 x 750 numbered tiles. These are stored in a JSON file. My aim is to pull the data and split each tile into separate arrays / chunks.
I already have it working, but I'm a python beginner and the code is really slow (it is handling 500,000+ numbers). Wondered if there was any faster method available for doing the same thing.
First I pull the json data into an array
with open("data.json") as data_file: data = json.load(data_file) arr = data["mapLayer"]["tiles"]
Then I run through the array and sort them into separate
chunk arrays based on their position:
x=0 y=0 for tile in arr: chunkPos = str(x/16) + "x" + str(y/16) chunks[chunkPos].append(tile) x += 1 // reset x pos when it reaches map edge if x == 750 x=0 y=y+1