Below is the code I used to read the second image. dat = np.genfromtxt(f, encoding='ascii', names= (' ', 'MVAbase', 'PSSEver', ' ', ' ', 'freq', ' ', ' ' ), dtype=None, max_rows=1, comments='/')
dat1 = np.genfromtxt(f, encoding='ascii', names= ('bus_num', 'bus_name', ' ', 'bus_type', ' ', ' ', ' ', 'bus_vol', 'bus_angle'), delimiter=",", dtype=None, max_rows= 24, usecols=(0,1,3,7,8), )
dat2 = np.genfromtxt(f, encoding='ascii', names= ('load_bus_num', 'load_name', '', '', '', 'Pload', 'Qload'), delimiter=",", dtype=None, max_rows=16, skip_header = 1, usecols=(0,1,5,6))
dat3 = np.genfromtxt(f, encoding='ascii', names= ('gen_bus_num', 'gen_name', 'Pgen', 'Qgen', 'Qmax','Qmin'), delimiter=",", dtype=float, max_rows=11, skip_header = 2, usecols=(0,1,2,3,4,5))
It's troublesome, but wouldn't it be necessary to parse well?
Fortunately, I see a pattern of 4 lines, so after reading each line, I think I'll try to parse it by tying 4 lines of ', '.join(lines[i:i+4])
into one line, and then passing it to
io.StringIO
.
© 2024 OneMinuteCode. All rights reserved.