I have a few text files that I created in a separate script, but I am at a loss on how to arrange the text file in the manner that I want.
The text file has three columns:
X, Y, [Z1, Z2, Z3, …]
Where the X/Y/Z values are arbitrary numbers.
There are several lines in this file, and the Z-lists are of varying lengths. What I would like is for the Z-lists to be separated so that there is only one Z value in each line, but the X/Y values would repeat based on how many elements are in the Z list.
For example, the first two lines of the text file are:
2306 3481 [2, -3, 82.6, 0.2]
2336 3408 [9, 0]
I would like for the two lines to become:
2306 3481 2
2306 3481 -3
2306 3481 82.6
2306 3481 0.2
2336 3408 9
2336 3408 0
Using
ast.literal_evalandstr.split: