In [2]:
step_1 = open("Sample_redone.txt", "r")

In [3]:
step_1


Out[3]:
<_io.TextIOWrapper name='Sample_redone.txt' mode='r' encoding='cp1252'>

In [4]:
step_2 = step_1.read()

In [31]:
step_3 = step_2.split(sep = "/m")
str(step_3)


Out[31]:
"['MSH|^~\\\\&|CERNER||PriorityHealth||||ORU^R01|Q479004375T431430612|P|2.3', 'PID|||001677980||SMITH^CURTIS||19680219|M||||||||||929645156318|123456789', 'PD1||||1234567890^LAST^FIRST^M^^^^^NPI', 'OBR|1|341856649^HNAM_ORDERID|000002006326002362|648088^Basic Metabolic Panel||', '20061122151600|||||||||1620^Hooker^Robert^L||||||20061122154733|||F|||||||||||20061122140000', 'OBX|1|NM|GLU^Glucose Lvl|59|mg/dL|65-99^65^99|L|||F|||20061122154733/n']"

In [33]:
step_4 = list(map(lambda x: x.split(sep="|"), step_3))

In [43]:
import pandas as pandas
step_4


Out[43]:
[['MSH',
  '^~\\&',
  'CERNER',
  '',
  'PriorityHealth',
  '',
  '',
  '',
  'ORU^R01',
  'Q479004375T431430612',
  'P',
  '2.3'],
 ['PID',
  '',
  '',
  '001677980',
  '',
  'SMITH^CURTIS',
  '',
  '19680219',
  'M',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '929645156318',
  '123456789'],
 ['PD1', '', '', '', '1234567890^LAST^FIRST^M^^^^^NPI'],
 ['OBR',
  '1',
  '341856649^HNAM_ORDERID',
  '000002006326002362',
  '648088^Basic Metabolic Panel',
  '',
  ''],
 ['20061122151600',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '1620^Hooker^Robert^L',
  '',
  '',
  '',
  '',
  '',
  '20061122154733',
  '',
  '',
  'F',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '',
  '20061122140000'],
 ['OBX',
  '1',
  'NM',
  'GLU^Glucose Lvl',
  '59',
  'mg/dL',
  '65-99^65^99',
  'L',
  '',
  '',
  'F',
  '',
  '',
  '20061122154733/n']]

In [44]:
dataframe = pandas.DataFrame(step_4)

In [45]:
dataframe


Out[45]:
0 1 2 3 4 5 6 7 8 9 ... 20 21 22 23 24 25 26 27 28 29
0 MSH ^~\& CERNER PriorityHealth ORU^R01 Q479004375T431430612 ... None None None None None None None None None None
1 PID 001677980 SMITH^CURTIS 19680219 M ... None None None None None None None None None None
2 PD1 1234567890^LAST^FIRST^M^^^^^NPI None None None None None ... None None None None None None None None None None
3 OBR 1 341856649^HNAM_ORDERID 000002006326002362 648088^Basic Metabolic Panel None None None ... None None None None None None None None None None
4 20061122151600 1620^Hooker^Robert^L ... 20061122140000
5 OBX 1 NM GLU^Glucose Lvl 59 mg/dL 65-99^65^99 L ... None None None None None None None None None None

6 rows × 30 columns


In [68]:
new = dataframe.rename(columns={'0':'a','1':'b'},inplace=True)

In [70]:
print(new)


None

In [ ]: