Loadtxt Examples

From Python Wiki

Jump to: navigation, search

Read a 2 column file

This example keeps prompting the user to enter a filename until it finds the file. It then reads the first column of the file into an array called time, and the second column into an array called response

 found_file=0
 while not found_file:
     FILE=raw_input('Enter Time History File > ')
     found_file=os.path.exists(FILE)
 time, response = np.loadtxt(FILE,unpack=True)
Personal tools