title: Converting csv files from subfolders into 1D numpy arrays and save them as pickle/numpy files
body: <p>I have folder with multiple subfolders. Each of the subfolders has a csv files (50 files). I want to write a function that read a csv file in each subfolder, this csv file has the same name in each folder,  convert it into a numpy array and save it in the same subfolder.</p>
  <p>I tried this function:</p>
  <pre><code>import glob
  import os
  import numpy as np 
  import pandas as pd
  
  #to loop in each subfolder and extract every csv fila has the name (train_ixs)
  
  files = glob.glob(&quot;C:\\Users\\user\\sample-size-test\\output\\500\\**\\train_ixs.csv&quot;, recursive = True)   
  
  for file in files :
      train = loadtxt(file,delimiter = &quot;,&quot;)
      for i in train :
          i = np.save(&quot;train_ixs.npy&quot;, train)
  </code></pre>
  <p>But it only saves the output (np array in the first subfolder).</p>
  <p>The ouput of this part of my function:</p>
  <pre><code>files = glob.glob(&quot;C:\\Users\\user\\sample-size-test\\output\\500\\**\\train_ixs.csv&quot;, recursive = True)
  
  for file in files :
      train = loadtxt(file,delimiter = &quot;,&quot;)
      print (train)
  </code></pre>
  <p>output:</p>
  <pre class="lang-none prettyprint-override"><code>[1176. 2553.  915. 3066. 1031. 6551. 1305. 3922. 5470.  178.  927. 1308.2393. 5891. 6515.]
  [4697. 6650. 2411. 5711. 3188. 5682. 1721. 1864. 1421. 2355. 4773. 3887.5054. 1727. 1561.]
  [2555. 1099. 4966. 2083. 1672. 2861. 2270. 2357. 3816. 4509. 3436. 4324.3027. 3741. 1078.]
  </code></pre>
  <p>I deleted most of the output to make it short.</p>
  <p>How to save each of these arrays in its subfolder?</p>