numpy array storing in file by python

# long arrays can be stored in csv files far more efficiently
import numpy as np
import csv

# uploading arrays in a csv file
arr1 = [i for i in range(500)]
arr2 = [i for i in range(1000)]
arr3 = [i for i in range(2000)]
# you can write('w') or append('a')
with open('record.csv', 'a') as record_append:
    np.savetxt(record_append, np.asarray([arr1]), delimiter=',')
    np.savetxt(record_append, np.asarray([arr2]), delimiter=',')
    np.savetxt(record_append, np.asarray([arr3]), delimiter=',')

# downloading them from the csv file
two_dim_arr = []  # each line of the file is an array element
with open('record.csv', 'r') as record_read:
    reader = csv.reader(record_read)
    for i, each_arr in enumerate(reader):
        two_dim_arr.append([eval(each) for each in each_arr])
        
# printing the arrays in lines
for each_line in two_dim_arr:
  print(each_line)

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
python store numpy array in file numpy savetext numpy savetxt how to save npy in desirable directory in python store numpy arrays in notebook how to save numpy array to file in python python save array to bw file create a .npy file save data to array python how to save a python array in a file save to .npy create numpy file data to array save as file how to store and read numpy array in file what is the best file extension to store a numpy array how to save a numpy array to file numpy save array how to save an array as matrix in python in a directory np.save example save np array to file save and load numpy array from csv store numpy array to a file save array numpy file how to save python array store np array to file Save array as a file save a numpy array to file python save vector to file save data in array python how to dump the contents of a numpy array into a file python array save to file save datasets with numpy how to convert array to npy file store numpy array in a file export list as numpy array keras how to save a numpy array to a file python save array npy numpy array file np.save in python how to export an array to an online file pyhton save array to file python np.save function print np array to file numpy save numpy append save large data 2 numpy array to file save numpy array to file save numpy file to create np array with file np.save python what does save in numpy do numpy save and load how to save array in python store numpy 2d array in file what is the best way python save array to file store numpy array in file save numpy array to .dat file save np array python python save data to array np array to file storing numpy arrays save numpy array best format to save arrays in binary save a numpy array how to save a numpy model using numpy.save how to save numpy array as file how to save an array can we store a numpy array in some file? how to save a numpy array how to store numpy array to local disk numpy np.save saving arrays python save ndarray to file how to store numpy array in file how to save np array how to save numpy array numpy array storing in file by python
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source