title: Update Numpy Array After Using Function to Delete Values
body: <p>I am working on a script that streams data and stores it into an array, however in order to conserve on memory I am hoping to unload some of this data into a CSV file. Here is what that function looks like:</p>
  
  <pre><code>def array_dump(file, array, targetSize, dumpSize):
      if np.size(array) &gt; targetSize:
          with open(file, 'a') as csvFile:
              for val in array[:dumpSize]:
                  csvFile.write(str(val))
                  csvFile.write('\n')
              csvFile.close()
  
          array = np.delete(array, np.s_[:dumpSize])
  </code></pre>
  
  <p>This function does successfully write to the CSV file, however it does not update the array. Here is the full Python script:</p>
  
  <pre><code>import csv
  import numpy as np
  from datetime import datetime
  
  def array_dump(file, array, targetSize, dumpSize):
      if np.size(array) &gt; targetSize:
          with open(file, 'a') as csvFile:
              for val in array[:dumpSize]:
                  csvFile.write(str(val))
                  csvFile.write('\n')
              csvFile.close()
          #array = array[dumpSize:]
          array = np.delete(array, np.s_[:dumpSize])
          print(np.size(array))
  
  
  currencyPair = "EUR_USD"
  global fileName
  now = datetime.now()
  fileName = "%s-%s-%s-%s.csv" % (currencyPair, now.year, now.month, now.day)
  file = open(fileName, 'a')
  file.close()
  
  global a 
  a = np.array([0.69126532,  0.51056279,  0.35202518,  0.13374911,  0.12558003,
          0.06426236,  0.8885468 ,  0.18412806,  0.96355032,  0.79755331,
          0.86043666,  0.51713643,  0.43547321,  0.34684145,  0.88541084,
          0.04065618,  0.25212305,  0.64831108,  0.9623507 ,  0.10511934,
          0.09817052,  0.15486658,  0.56793785,  0.50717163,  0.38677482,
          0.63625237,  0.33494367,  0.71391515,  0.53597436,  0.44326044,
          0.40208125,  0.32963563,  0.78210655,  0.23943754,  0.74833578,
          0.94591554,  0.29412408,  0.71934844,  0.99787723,  0.92264647,
          0.94351218,  0.19185273,  0.14808887,  0.91515938,  0.48011523,
          0.33024851,  0.39953296,  0.18908139,  0.7347978 ,  0.09855765,
          0.06552421])
  
  #print(a)
  print(np.size(a))
  array_dump(fileName, a, 50, 25)
  print(np.size(a))
  </code></pre>
  
  <p>Is there any way I can use this function to unload, delete and update my array? Thanks.</p>