-
Notifications
You must be signed in to change notification settings - Fork 4
/
read_ascii_tools.py
35 lines (26 loc) · 926 Bytes
/
read_ascii_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#THIS MODULE CONTAINS SCRIPTS FOR READING ASCII (TEXT) FILES
#EACH SUBROUTINE IS SEPARATED BY A LINE --------
#-----------------------------------------------------------------------------
#
#Reads a single column ASCII
#
#INPUT
# file - input file name, including full path, of the ASCII file to be read
#
#
def read_sglcol_ascii(file):
import numpy as np #import numpy for array manipulation
f = open(file, 'r') #open the input file, FILE
line = f.readlines() #read individual lines in file
out = [float(i) for i in line] #convert lines in list to floating points
arr = np.array(out) #convert list to array
f.close() #close the file
return arr #return the array
#-----------------------------------------------------------------------------
#
#Reads a multi-column ASCII
#
#INPUT
# file - input file name, including full path, of the ASCII file to be read
#
#