Entity Framework - Powershell - Asked By David Baez on 19-Feb-10 07:20 PM

HI experts,
Can someome help me I'm trying to create mutiple csv files from data I have imported into powershell I have tried Export-csv C:\data.csv but it;s only giving one file with all the data. Here is the script line..

Import-csv c:\test.csv | where {$_.department -match "Network"} export.csv C:\Data.csv 
Import-csv c:\test.csv | where {$_.department -match "Development"} export.csv C:\Dev.csv 
I would like to know how to export to different csv files.

Thank YOu..
 


Hesham Amin replied to David Baez on 05-Mar-10 07:30 AM
It should be like this: (I think you forgot the pipeline)
Import-csv c:\test.csv | where {$_.department -match "Network"} | export-csv C:\Data.csv
Import-csv c:\test.csv | where {$_.department -match "Development"} | export-csv C:\Dev.csv
David Baez replied to Hesham Amin on 05-Mar-10 08:56 AM
Thank You Hesham, however my point is that I have 100 department which means I would have to type 100 lines of code. I may need to use the foreach-object to make this work better do you have any suggestions?
Hesham Amin replied to David Baez on 06-Mar-10 06:46 AM
Can you send a sample csv file?
David Baez replied to Hesham Amin on 06-Mar-10 07:02 AM
Hi Hesham,

please send me your email so i can send you a CSV file....thank you.
Hesham Amin replied to David Baez on 06-Mar-10 01:09 PM
You can just post a sample csv data to know the structure of the file and how data look like. drop a few lines in the forum.