def _read_ZLS_format_file(filepath):
col_names = ['line_name', 'year', 'day', 'hour', 'minute', 'second',
'sensor', 'spring_tension', 'cross_coupling',
'raw_beam', 'vcc', 'al', 'ax', 've2', 'ax2', 'xacc2',
'lacc2', 'xacc', 'lacc', 'par_port', 'platform_period']
col_widths = [10, 4, 3, 2, 2, 2, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 6]
time_columns = ['year', 'day', 'hour', 'minute', 'second']
# read into dataframe
df = pd.read_fwf(filepath, widths=col_widths, names=col_names)
day_fmt = lambda x: '{:03d}'.format(x)
time_fmt = lambda x: '{:02d}'.format(x)
t = df['year'].map(str) + df['day'].map(day_fmt) + \
df['hour'].map(time_fmt) + df['minute'].map(time_fmt) + \
df['second'].map(time_fmt)
# index by datetime
df.index = pd.to_datetime(t, format='%Y%j%H%M%S')
df.drop(time_columns, axis=1, inplace=True)
return df
评论列表
文章目录