-3

I tried assigning a list of directories on a numpy array, but somehow the array only stores the first letter, not the full address of strings.

lasdir=np.array(range(4), dtype=str).reshape(2,2)
i=0
for root, dirs, files in os.walk(source_dir):
    for file in files:
        if (file.lower().endswith(".las")):
            lasdir[i,0]=file
            lasdir[i,1]=os.path.join(root, file)
            i=i+1

Does anybody know why?

kyle
  • 691
  • 1
  • 7
  • 17
Leon
  • 69
  • 2
  • 11

1 Answers1

0

When usings a str dtype, it uses fixed-length strings. As suggested in this answer, you're better off using dtype object.

So your first line could transform to :

lasdir = np.empty((2,2), dtype=object)
Aule Mahal
  • 688
  • 5
  • 10