I am new to Python. I am trying to port a BASH script I wrote to Python so I can learn the language.
I have a csv file with 5 columns. The first column is a host name. Second through 5th have different attributes of the host (environment, use, OS, architecture). I want to allow the user to pick one type from each column and output the hostnames that match the users request (i.e. list all hostnames that are Oracle servers in Production running Red Hat 64 bit). The user will pick from a text menu that is built from the csv file.
The initial menu lists each of the 2nd through 5th column names. The user can pick one (i.e. Environment) column, the csv file gets read in and picks the environment type (TEST, QA, PROD...). The user picks one.
Now I have the problem, want to go back to the initial menu and let the user pick another column. Do I have to read the file again and pick out the new column choice or can I keep the initial file read in memory (this file is small with only about 60 rows) and just pick the column I want from that?
An example row looks like:
<hostname>,PROD ,Oracle_Server, Red_Hat,64
Thanks,
John
PS - The ideal thing would be to create a database from the csv file then write a select statement to pick out the hostnames i need but for some reason it was decided not to install sqlite on this machine...I wish there was....
I have a csv file with 5 columns. The first column is a host name. Second through 5th have different attributes of the host (environment, use, OS, architecture). I want to allow the user to pick one type from each column and output the hostnames that match the users request (i.e. list all hostnames that are Oracle servers in Production running Red Hat 64 bit). The user will pick from a text menu that is built from the csv file.
The initial menu lists each of the 2nd through 5th column names. The user can pick one (i.e. Environment) column, the csv file gets read in and picks the environment type (TEST, QA, PROD...). The user picks one.
Now I have the problem, want to go back to the initial menu and let the user pick another column. Do I have to read the file again and pick out the new column choice or can I keep the initial file read in memory (this file is small with only about 60 rows) and just pick the column I want from that?
An example row looks like:
<hostname>,PROD ,Oracle_Server, Red_Hat,64
Thanks,
John
PS - The ideal thing would be to create a database from the csv file then write a select statement to pick out the hostnames i need but for some reason it was decided not to install sqlite on this machine...I wish there was....
Comment