I have a text file that looks like this:
UWI/API WELLNAME WELLNO LABEL OPER PRODFM SURFLAT SURFLON BOTLAT BOTLON PERFTOP PERFBASE PERFSOURCE WELL WELL WELL WELL WELL WELL WELL SYM
ELEV_KB TD COMP_DATE SPUD_DATE INJLIQ INJGAS INJWTR
49025000510000 CH039068 3-A 03WC2NE01 STANOLIND O&G CO 603WLCK2 43.384316 -106.275540 0.000000 0.000000 1525.0 1815.0 4847.00 1815.00 03/20/1925 01/01/1925 0.00 857224.00 6538652.00CO2-INJ
49025000540000 CH036906A 8-A 08WC2NE01 STANOLIND O&G CO 43.383111 -106.278775 0.000000 0.000000 0.0 0.0 1842.00 10/07/1926 01/01/1926 0.00 757266.00 2287490.00CO2-INJ
49025000550000 CH03906B 12-A 12WC2NE01 STANOLIND O&G CO 603WLCK 43.383171 -106.272200 0.000000 0.000000 1448.0 1703.0 4896.00 1916.00 07/23/1924 01/01/1924 0.00 1157524.00 9007039.00CO2-INJ
49025000550000 1448.0 1451.0
49025000550000 1700.0 1703.0
49025000580000 CH03906B 19-A 19WC2NE01 STANOLIND O&G CO 43.380695 -106.280337 0.000000 0.000000 0.0 0.0 1833.00 08/27/1924 01/01/1924 0.00 3602831.00 8002146.00CO2-INJ
49025000580000 1565.0 1833.0
49025000590000 CH03906B 23-AX 23WC2NE01 STANOLIND O&G CO 603WLCK2 43.380810 -106.273800 0.000000 0.000000 1842.0 1916.0 1927.00 10/19/1923 01/01/1923 0.00 2673371.00 9392905.00CO2-INJ
49025000590000 0.0 0.0
When I run this code, the output puts all of row one into one column. I want the first column to be "UWI/API", the second column to be "WELLNAME", ect... As you can see, the data is not separated by a comma, just by spaces. The data is sort of messed up? It is not aligned. The headers should be "UWI/API" to "INJWTR."
Here is my code:
import pandas as pd
df = pd.read_csv(r'C:/Users/mmcintyre/Documents/Teresa CO2 Injectors_Spaces.txt',sep=r'\s{2,}')
df.to_csv(r'C:/Users/mmcintyre/Documents/Teresa.csv',index=None)
And the output is this:https://sru365edu-my.sharepoint.com/:x:/g/personal/mam1064_sru_edu/Ebq0tpHveAJBu710UcDt82IB23gmRs6nNrTE-MtDUgkU6Q?e=byhjuL
I highlighted the rows that aren't in the right position. I'm not sure if this even fixable.
Thanks! Morgan