T
T
Tina Sokolova2020-05-29 11:05:47
Python
Tina Sokolova, 2020-05-29 11:05:47

Translation of table data (x, y) from dat file to list?

I'm having a problem reading a datian file. I am reading data and writing to numpy array:

spoiler
m = 'model_spectrum_090412.dat'
f = open(m, 'r')
pmod = f.read()
model = np.array( for k in f)
f.close()

g = '090412.dat'
f1 = open(g, 'r')
pdat = f1.read()
data = np.array( for t in g)
f1.close()


But then, when checking what happened, it gives out a 0-dimensional array, and when you try to translate it into a list, the desired one does not work. Of course, if there is an option to filter the data of one graph, not through the list, by selecting the nearest points to it from the other, that is, to remove from the model graph all points that do not have the nearest point from the experimental one.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ishmatov_rus, 2020-05-29
@lana_voskr

f = open("data.dat", "r", encoding="utf-8")
n = []
for i in f:
n.append([i.split()[0], i.split() [1]])
print(n)
f.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question