{"id":7741,"date":"2015-02-19T11:59:00","date_gmt":"2015-02-19T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2015\/02\/19\/powertip-get-row-from-csv-file-based-on-value\/"},"modified":"2019-02-18T10:30:34","modified_gmt":"2019-02-18T17:30:34","slug":"powertip-get-row-from-csv-file-based-on-value","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-get-row-from-csv-file-based-on-value\/","title":{"rendered":"PowerTip: Get Row from CSV File Based On Value"},"content":{"rendered":"<p><b style=\"font-size:12px\">Summary<\/b><span style=\"font-size:12px\">: Use Windows PowerShell to get a row from a CSV file based on a specific value.<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;How can I use Windows PowerShell 4.0 to look up a specific row from a CSV file I imported into a variable?<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Use the&nbsp;<b>Where<\/b>&nbsp;method, and use a match pattern to search on a specific column and value,<span style=\"font-size:12px\">&nbsp;for example:<\/span><\/p>\n<p style=\"margin-left:120px\">$topics = import-csv -Path C:\\lit\\Shakespeare.txt<\/p>\n<p style=\"margin-left:120px\">$topics.Where({$PSItem.play -eq &#039;hamlet&#039;}).topic<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to get a row from a CSV file based on a specific value. &nbsp;How can I use Windows PowerShell 4.0 to look up a specific row from a CSV file I imported into a variable? &nbsp;Use the&nbsp;Where&nbsp;method, and use a match pattern to search on a specific column and value,&nbsp;for example: [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[169,356,3,4,45],"class_list":["post-7741","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-csv-and-other-delimited-files","tag-powertip","tag-scripting-guy","tag-scripting-techniques","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to get a row from a CSV file based on a specific value. &nbsp;How can I use Windows PowerShell 4.0 to look up a specific row from a CSV file I imported into a variable? &nbsp;Use the&nbsp;Where&nbsp;method, and use a match pattern to search on a specific column and value,&nbsp;for example: [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/7741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=7741"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/7741\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=7741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=7741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=7741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}