Jun 262013

Turning CSV-Files into “Databases”

Let’s assume you have a CSV file with information that you need to frequently look up. For example, the CSV file may contain server names and certain configuration settings for them.

To easily look up items in your CSV file, you can turn it into a hash table. Let’s first create a test CSV file to play with:

# create
test CSV file




Year, ID, Description, Metric









Next, let’s turn this CSV file into a lookup table, using the column “Servername” as key column:

analyzing any CSV file content:



# listing
CSV file keys:



It works! Note how the code uses Group-Object to create the lookup table. Note also that its parameter -Property determines the CSV file column it uses to index the information. You just need to make sure that the information in this column is unique (has no duplicate entries).

Now it is very easy to lookup information from your CSV file data:

# looking
up individual server information:



# testing
whether a given server is contained in list:


Source: Powershell.com


  One Response to “Powershell Turning CSV-Files into “Databases””

  1. This could be useful

Leave a Reply