![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Import-CSV piped hashtable access Howdy, I've been working on a filter that takes a piped input from Import-CSV, merges additional columns, and is redirected to Export-CSV. Import-CSV | myMerge-CSV | Export-CSV It is my beleive that Import-CSV creates a hashtable with the column headings as key fields. While in the myMerge-CSV function/filter I can not convert $_ to a native hashtable or System.Collections.Hashtable. I can convert to string "@{key1=value1; key2=value2}", but can not add this to local hashtable being merged within the function. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Import-CSV piped hashtable access I just did a gm on an imported csv, and it appears that rather than creating a hash table, it's creating a string of custom ps objects, with note properties for each of the column headings. I believe a .csv is a multi-valued array, whereas a hashtable is single valued. "Terry E Dow" wrote: > Howdy, > > I've been working on a filter that takes a piped input from Import-CSV, > merges additional columns, and is redirected to Export-CSV. > > Import-CSV | myMerge-CSV | Export-CSV > > It is my beleive that Import-CSV creates a hashtable with the column > headings as key fields. While in the myMerge-CSV function/filter I can not > convert $_ to a native hashtable or System.Collections.Hashtable. I can > convert to string "@{key1=value1; key2=value2}", but can not add this to > local hashtable being merged within the function. > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Import-CSV piped hashtable access "Rob Campbell" <RobCampbell@discussions.microsoft.com> wrote in message news:74EFD865-9A53-4DB7-9935-B29A0C563456@microsoft.com... >I just did a gm on an imported csv, and it appears that rather than >creating > a hash table, it's creating a string of custom ps objects, with note > properties for each of the column headings. Right. This example will illustrate it with what Terry is trying to achieve: PS> type liste.csv Image,FirstName,LastName D:\EXPORT\image0001.tif,JEAN,VALJEAN D:\EXPORT\image0002.tif,LOUIS,GEORGES D:\EXPORT\image0003.tif,FELIX,LOUIS PS> filter merge-csv { >> add-member -in $_ NoteProperty FullName "$($_.FirstName) >> $($_.LastName)" -passthru >> } >> PS> import-csv liste.csv | merge-csv Image FirstName LastName FullName ----- ------ --- -------- D:\EXPORT\image0001.tif JEAN VALJEAN JEAN VALJEAN D:\EXPORT\image0002.tif LOUIS GEORGES LOUIS GEORGES D:\EXPORT\image0003.tif FELIX LOUIS FELIX LOUIS PS> import-csv liste.csv | merge-csv | export-csv liste2.csv -notype PS> type liste2.csv Image,FirstName,LastName,FullName D:\EXPORT\image0001.tif,JEAN,VALJEAN,"JEAN VALJEAN" D:\EXPORT\image0002.tif,LOUIS,GEORGES,"LOUIS GEORGES" D:\EXPORT\image0003.tif,FELIX,LOUIS,"FELIX LOUIS" Hope that helps, Jacques |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Return from a piped foreach in function | PowerShell | |||
| I can't access this hashtable | PowerShell | |||
| Working with Piped output | PowerShell | |||
| String formatting of piped dates | PowerShell | |||
| Any limit to the size of a .NET object that can be piped from one cmdlet to another? | PowerShell | |||