I'm using PANDAS Dataframe to get the data from CSV file and opting to choose the desired column data which is working fine. However, in the hostData
Dataframe i'm looking specially for (data['Safe']=='KDS-PDC-DEFAULT-UNIX-ROOT')
portion so, as i have multiple safes as i mentioned below the CyberArk Safes
within the doc string hence i'm looking forward to rather putting the safe name manually on the code it could ask on the user input.
While asking for the User Input to give the safe name if it could display the current safe names which is within doc string.
#!/grid/common/pkgs/python/v3.6.1/bin/python3
from __future__ import print_function
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE,SIG_DFL)
import csv
import pandas as pd
##### Python pandas, widen output display to see more columns. ####
pd.set_option('display.height', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('expand_frame_repr', True)
############# CyberArk Safes ################
'''
KDS-KDC-DEFAULT-UNIX-ROOT
KDS-PDC-DEFAULT-UNIX-ROOT
KDS-CDC-DEFAULT-UNIX-ROOT
'''
################# PANDAS Extraction ###########
data = pd.read_csv('/home/karn/plura/Test/Python_Panda/InventoryReports06.csv', usecols=['Platform ID', 'Safe', 'Target system address', 'Failure reason'])
hostData = data[(data['Safe']=='DC') | (data['Safe']=='KDS-PDC-DEFAULT-UNIX-ROOT')][['Safe', 'Target system address']]
hostData.reset_index(level=0, drop=True)
Expected Output:
$ python CyberSafe.py
The Current SafeName Available are:
KDS-KDC-DEFAULT-UNIX-ROOT
KDS-PDC-DEFAULT-UNIX-ROOT
KDS-CDC-DEFAULT-UNIX-ROOT
Please Enter the SafeName:
Any help or suggestion will highly be appreciated.