I'm working on a data import, which are in the format, as in the example:
[-2.814285863362681, -2.814158589901394, -2.8123844084634873]
[-2.874285863362681, -2.054158589901394, -2.6523844084634873]
.
.
.
I used this code to import, already removing '\ n' with strip ()
with open(coeffs_csv) as inp:
signals_coeffs_cluster = inp.readlines()
signals_coeffs_cluster = [x.strip() for x in signals_coeffs_cluster]
But I need this data in float and array format, so I worked on the code for just the second line:
signal_1.append(signals_coeffs_cluster[1])
signal_1 = [k.replace('[', '').replace(']', '') for k in signal_1]
And this returns me a size 1, that is, everything is concatenated within signal_1, I can not, for example make signal_1 [2], since there is no position.
How do I extract a line from the input file and separate them as individual float array?
array_1 = [-2.814285863362681, -2.814158589901394, -2.8123844084634873]
array_2 = [-2.874285863362681, -2.054158589901394, -2.6523844084634873]
And so on?
EDIT:
I use this code to export:
coeffs = cA3.tolist()
with open(coeffs_csv, "a") as output:
json.dump(coeffs, output)
output.write('\n')
Thank you