title: How to combine files in folder into one file and cut it by indexes given?
body: <p>I need to combine data files into 1 file using indexes in files because the necessary data is between them. And save the data as NumPy array.
  Indexes are &quot;Data_start&quot; and &quot;Data_end&quot;.
  Here is the code I'm working on:</p>
  <pre><code>import os
  import numpy as np
  
  f = open('combined.csv', 'w')                   # create file
  filenames = os.listdir('data')                  # data files list in folder &quot;data&quot;
  with f as combined:                             # open file 'combined.csv'
      os.chdir('data')                            # change folder to data folder
      for filename in filenames:                  # for each name in file
          with open(filename) as infile:          # read filename in file as 'infile'
            # here is the code to cut the file between [datastart:dataend] indexes ?
              combined.write(infile.read())       # write in 'combined' what you read in file
          combined.write('\n');                   # put 'enter' after
  
  #here is the code to save it as NumPy array?
  
  </code></pre>
  <p>in my case, it saves the file as one long line or as many long lines, but not as a normal CSV.
  Thanks in advance!</p>