SHARE
TWEET

Untitled

a guest Jul 18th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. names_needed = ['PCC', 'PSP', 'ASP']
  2.      
  3. PCC WITH NOTHING
  4. ABB,CAI null V00011 11/06/18
  5. ANDERS,SAND null V000103 07/10/17
  6. KUCHEN,SARA null V00011 03/21/19
  7.  
  8. PSP SECONDARY
  9. MUNCH,TORY null V000113 04/08/19
  10. ACOSTA,AD null V00010 06/19/17
  11.  
  12. PCC WITH SOEMTHING
  13. BEC,RUMA null V00011 04/17/19
  14. BECE,COR null V00010 10/25/16
  15. TORRE,M null V0001143 06/06/19
  16.  
  17. ASP HAS IT
  18. XON,ANDREA null V00011 03/27/19
  19.  
  20. PSP Wanted
  21. NICK,SON null V00011 05/20/19
  22. JUARE,SABIO null V00011 04/02/19
  23.      
  24. PCC:
  25. [ABB,CAI null V00011 11/06/18
  26. ANDERS,SAND null V000103 07/10/17
  27. KUCHEN,SARA null V00011 03/21/19
  28. BEC,RUMA null V00011 04/17/19
  29. BECE,COR null V00010 10/25/16
  30. TORRE,M null V0001143 06/06/19]
  31.  
  32. PSP:
  33. [MUNCH,TORY null V000113 04/08/19
  34. ACOSTA,AD null V00010 06/19/17
  35. NICK,SON null V00011 05/20/19
  36. JUARE,SABIO null V00011 04/02/19]
  37.  
  38. ASP:
  39. [XON,ANDREA null V00011 03/27/19]
  40.      
  41. names_needed = ['PCC', 'PSP', 'ASP']
  42.  
  43. ## Key word list
  44. key_word_list = []
  45.  
  46. ## Empty list to save all lines
  47. all_lines = []
  48.  
  49. ## Open text file
  50. read_text_file = r'text_file.TXT'
  51.  
  52. ### Open the file
  53. with open(read_text_file) as f:
  54.     # For each line
  55.     for line in f:
  56.         # For each line split by new line and get the 0th index
  57.         each_line = line.split('n')[0]
  58.         # Strip off white space characters
  59.         stripped_line = each_line.strip()
  60.  
  61.         # Iterate the list of key values   **** HERE is WHERE I AM ITERATING KEY WORD
  62.         for i in names_needed:
  63.             if i in stripped_line:
  64.                 key_word_list.append(i)
  65.                 all_lines.append(stripped_line)
  66.  
  67.             else:
  68.                 break
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top