Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Search DataTable created from csv's

$
0
0

I have created a datatable from two csv files and now I want to search for a string (i.e. srv_2015P) and if found display in a grid.  

Merged the csv's

$csvFiles = Get-ChildItem 'C:\Temp\ServAcct' -recurse -force | Where { $_.Name -like "*Accts.csv" } | Foreach-Object -process { $_.FullName }; 

$content = @();

# Process each file

foreach($csv in $csvFiles) 

{ $content += Import-Csv $csv -Header ID,SrvAcct,SideIndicator; }

[System.Data.DataTable]$dt = $content | ToTable -TableName "Merged";

 

Can this be done for searching?

[System.Data.DataTable]$dt = new-object Data.datatable("Merged")

TextBox -DBReadTable $dt;

[String]$Query = "Select [SrvAcct], [SideIndicator] from " + $dt + "Where SrvAcct like" + "'%" + [search string] + "%'";

Thank you


Viewing all articles
Browse latest Browse all 6937

Trending Articles