I'm trying to create a dataframe from a .txt file. I was able to define 4 columns but I'm having trouble with the information that's stored inside each row. For each row in respect to its header, it contains all of the information that is found in the .txt file. I would like for it to only contain the specific information the header outlines but I'm not sure how I can extract the information in python. Please let me know of any ideas I can try to apply.
[This is what the .txt file looks like][1] [1]: https://i.stack.imgur.com/dic58.jpg
This is the code I have right now:
file = open('BOCA copy.txt','r')
df = pd.read_csv('BOCA copy.txt')
df[['YYMMMDD']] = df['site YYMMMDD yyyy.yyyy __MJD week d reflon _e0(m) __east(m) ____n0(m) _north(m) u0(m) ____up(m) _ant(m) sig_e(m) sig_n(m) sig_u(m) __corr_en __corr_eu __corr_nu _latitude(deg) _longitude(deg) __height(m)'].str.split('YYMMMDD',1,expand=True)
df[['east(m)']] = df['site YYMMMDD yyyy.yyyy __MJD week d reflon _e0(m) __east(m) ____n0(m) _north(m) u0(m) ____up(m) _ant(m) sig_e(m) sig_n(m) sig_u(m) __corr_en __corr_eu __corr_nu _latitude(deg) _longitude(deg) __height(m)'].str.split('east(m)',1,expand=True)
df[['north(m)']] = df['site YYMMMDD yyyy.yyyy __MJD week d reflon _e0(m) __east(m) ____n0(m) _north(m) u0(m) ____up(m) _ant(m) sig_e(m) sig_n(m) sig_u(m) __corr_en __corr_eu __corr_nu _latitude(deg) _longitude(deg) __height(m)'].str.split('north(m)',1,expand=True)
df[['up(m)']] = df['site YYMMMDD yyyy.yyyy __MJD week d reflon _e0(m) __east(m) ____n0(m) _north(m) u0(m) ____up(m) _ant(m) sig_e(m) sig_n(m) sig_u(m) __corr_en __corr_eu __corr_nu _latitude(deg) _longitude(deg) __height(m)'].str.split('up(m)',1,expand=True)
del df['site YYMMMDD yyyy.yyyy __MJD week d reflon _e0(m) __east(m) ____n0(m) _north(m) u0(m) ____up(m) _ant(m) sig_e(m) sig_n(m) sig_u(m) __corr_en __corr_eu __corr_nu _latitude(deg) _longitude(deg) __height(m)']
df
[This is the output of the code above][2] [2]: https://i.stack.imgur.com/twojB.jpg