title: Loop over multiple files to merge according their names
body: <p>I'm a new python. I have for loop function gives me a folder contains 100 files "the data inside is numbers and the nuber of raws are the same" like the follow:</p>
  
  <pre><code>A_0.20_1_.txt        for example   A_0.20_1_    B_0.20_1_      
  B_0.20_1_.txt                         1            4
  A_0.20_2_.txt                         2            5
  B_0.20_2_.txt                         3            6
  
  A_0.40_1_.txt
  B_0.40_1_.txt
  A_0.40_2_.txt
  B_0.40_2_.txt
  
  and so on.....
  </code></pre>
  
  <p>These files saved in a folder named output
  I need to merge the two files form the output folder into one file like:</p>
  
  <pre><code>merged_A_B_0.20_1_.txt       for example   merged_A_B_0.20_1_
  merged_A_B_0.20_2_.txt                        1    4
                                                2    5
  merged_A_B_0.40_1_.txt                        3    6
  merged_A_B_0.40_2_.txt
  
  and so on.....
  </code></pre>
  
  <p>I tried to use the following code:</p>
  
  <pre><code>filename_list = [f for f in os.listdir(r'C:\Users\output\')if os.path.isfile(f)] 
  columns = []
  for filename in filename_list:
      f=open(filename)
      x = np.array([float(raw) for raw in f.readlines()])
      columns.append(x)
  columns = np.vstack(columns).T
  np.savetxt('filename_out.txt', columns) 
  </code></pre>
  
  <p>But it doesn't work and give me error</p>
  
  <pre><code>     Traceback (most recent call last):
  
  File "&lt;ipython-input-6-5df3067f04e7&gt;", line 1, in &lt;module&gt;
  runfile('C:/Users/user/Downloads/combine 2 files new2.py', wdir='C:/Users/user/Downloads')
  
  File "C:\ProgramData\Anaconda3\lib\site-
   packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
  execfile(filename, namespace)
  
  File "C:\ProgramData\Anaconda3\lib\site-
    packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
  exec(compile(f.read(), filename, 'exec'), namespace)
  
  File "C:/Users/user/Downloads/combine 2 files new2.py", line 22, in 
  &lt;module&gt; columns = np.vstack(columns).T
  
  File "C:\ProgramData\Anaconda3\lib\site-
  packages\numpy\core\shape_base.py", line 230, in vstack
  return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
  
  ValueError: need at least one array to concatenate    
  </code></pre>
  
  <p>Please, any help?</p>