I try to display a numpy file, then display its correct length, I put my file in folder:
import numpy as np
import os
path= "C:\\Users\\user\\Folder"
files= os.listdir(path)
filepath= os.path.join(path, files[0])
file0= np.load(filepath)
print(file0)
print (len(file0))
The result is an imbrication of tables, which gives me as length=1 instead of length=8000 :
[[ 0.01437869 0.01506449 0.01579909 ..., 0.04166172 0.0417285
0.04172079]]
1
But I need to have is:
[ 0.01437869 0.01506449 0.01579909 ..., 0.04166172 0.0417285
0.04172079]
8000
How to resolve this problem please.
1 Answer 1
This should work:
file0= np.load(filepath)[0]
answered Apr 27, 2017 at 9:54
Trolldejo
4661 gold badge7 silver badges20 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Jaime
I like this syntax to unpack single item sequences better, but YMMV:
file0, = np.load(filepath).lang-py
.ravel()ornp.squeeze()..shapeinstead oflen().file0.shapeis (1,8000).