SHARE
TWEET

Untitled

a guest Jun 25th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. df1['OS Version'].str.contains(MATCH_PATT)
  2.      
  3. df1[~df1['Aux Site'].str.contains('VCAD')]
  4.      
  5. import pandas as pd
  6.  
  7. MATCH_PATT = "AIX|CentOS|Fedora|RHEL|SunOS|SuSE|Ubuntu|(?<!?)?(?!?)"
  8. COLUMN_NAMES = ['Hostname', 'IP Address', 'Aux Site', 'OS Version']
  9. df1 = pd.read_csv('/home/karn/plura/Test/Python_Panda/CyberArk/host.txt', delimiter = "t", usecols=COLUMN_NAMES, encoding='cp1252',  dtype='unicode')
  10. df2 = df1[df1['OS Version'].str.contains(MATCH_PATT,  na=False)][['Hostname', 'IP Address', 'Aux Site', 'OS Version']]
  11. df2[['Hostname', 'Aux Site']] = df2[['Hostname', 'Aux Site']].replace({'*': ''}, regex=True)
  12. df2.to_csv('new_survey_list-1', index=False)
  13.      
  14. df1[(df1['OS Version'].str.contains(MATCH_PATT,  na=False)) & (~df1['Aux Site'].str.contains('VCAD'))] [['Hostname', 'IP Address', 'Aux Site', 'OS Version']]
  15.      
  16. Hostname Aux Site OS Version
  17. vlfox01 VCAD    CentOS 5.5
  18. vlfox02 VCAD    RHEL 7.1
  19. vlfox03 VCAD    RHEL 6.8
  20. vlbrk01 brackn  RHEL 5.8
  21. vlbrk02 brackn  SunOS 5.9
  22. vlbrk03 brackn  RHEL 5.5
  23. vlbrk04 brackn  RHEL 6.3
  24. vlbrk05 brackn  RHEL  5.5
  25.      
  26. vlbrk01 brackn  RHEL 5.8
  27. vlbrk02 brackn  SunOS 5.9
  28. vlbrk03 brackn  RHEL 5.5
  29. vlbrk04 brackn  RHEL 6.3
  30. vlbrk05 brackn  RHEL  5.5
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top