title: Extracting data from a text file in python
body: <p>I am using the below code in which i am reading a text file and trying to extract the required data. However, I am getting error 'expected string or bytes-like object'.</p>
  
  <p>Since I cannot attach the file, I am pasting the text file contents over here:</p>
  
  <pre><code>FIRCOSOFT-FOF-ProCESS
  HDR ./INPUT/201911098765-SWFTNA-ID3751V1_1.DAT    65764645454 FMFILE LINUX  5.7.2.1
  H   156898900   0         50K     0 6 -1 WCP002862      1   WORLDCHECK-PREMIUM    EMBARGOJHUHUGHJHHHHHHHH KHH,KHHUHJ
  ## $$$$ 
  \000000\0000000000000000000000000000000\00000000000   NO :20:9E40FGTE23555CEasw3NN :23B: IHDUHFUEHRUEURH99090SNDNNDB
  2019-04-15 FCMBATCH  0101010 01 01 01 0 1 01
  </code></pre>
  
  <p>My code:</p>
  
  <pre><code>os.chdir('C:\\Users\\waliaar\\Desktop')
  file=open("Test_data.txt", "r", encoding='UTF-8')
  file.read()
  a=re.compile(':20:(.*) :23B:')
  z=a.findall(file)
  </code></pre>
  
  <p>Kindly help me with a solution. I want to extract words between <code>:20:</code> and <code>:23B:</code> from the attached text file and put them into excel file with a column named text_id.</p>
  
  <pre><code>Excel output ---
  
  text_id
  9E40FGTE23555CEasw3NN
  </code></pre>