Home > front end >  Load txt and convert to npy keeping the same shape
Load txt and convert to npy keeping the same shape

Time:10-05

I have a .txt file with a dataset containing more than 20k float values and 30 features. I'm trying to convert it in a .npy file, which should have a shape of (23706, 30). The problem is that when I load it through the function:

array_from_file = np.genfromtxt("machine-1-5.txt", dtype=str)

and I try to print its shape, I get a single array with all the values and a shape= (23706,)

How can I load it keeping its original shape? I don't understand it I need to use another function

CodePudding user response:

This works,

a = np.loadtxt("machine-1-5.txt", dtype=str, delimiter=',')
print(a.shape)
(23706, 38)
  • Related