I am reading a JSON file with data in it and I am trying to ensure that each file that is created in my code has a unique value. However sometimes the value is a string either like "data" or some number as a string
So if the file I are creating 3 times is called "data", I want to convert it into:
data_0
data_1
data_2
Also if the value is the a number (but it string format) such as 145 I want to change that to:
145
146
147
Currently my code produces something like this:
data_0,
data_0_1,
data_0_1_2
or
145_0,
145_0_1,
145_0_1_2
Below is my code:
for index in range(0,len(test)):
test[index]["value"]= test[index]["value"] + str(number)
I am using str(number)
because otherwise I get this error:
TypeError: coercing to Unicode: need string or buffer, int found
JSON file example:
"test": [{
"type": "text",
"value": "data"
}, {
"type": "integer",
"value": "145"
}]
Any advice would be appreciated.