Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Tachekentya |
Hello Everyone,
I have a 2d array something like :
[50,100,150]
[2000,1000,2000]
I want to save this array in a text file, for this I’m using the following code:
func save(content, filename : String):
var file = File.new()
if (file.open(str("res://R//", filename, ".txt"), File.WRITE)== OK):
for i in range(content.size()):
file.store_line(str(content[i]) + "\r")
file.close()
The problem is that the bracket appear in the text file. How can I remove from the text file
To create the 2D array content I’m using this
func createArrayForTXT():
var content = []
content.append("a")
var array_ = ["b"]
content.append([])
for x in range(array1.size()):
array_.append(array1[x])
array_.append(0)
content[1].append(array_join(array_,","))
var fileName : String
for x in range(aRRAY2.size()):
content.append([])
array_ = [aRRAY2[aRRAY2.size() - 1 - x]]
for y in range(array1.size()):
array_.append(y+x+1)
array_.append(0)
content[x+2].append(array_join(array_,","))# + "\r")
fileName = "textFile1"
save(content, fileName)
the result of this is
a
[b,1,2,3,4,5,0]
[50,1,2,3,4,5,0]
[40,2,3,4,5,6,0]
[30,3,4,5,6,7,0]
[20,4,5,6,7,8,0]
[10,5,6,7,8,9,0]
and what I need is
a
b,1,2,3,4,5,0
50,1,2,3,4,5,0
40,2,3,4,5,6,0
30,3,4,5,6,7,0
20,4,5,6,7,8,0
10,5,6,7,8,9,0
Thanks!!