Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Creating files from Data Table

Reply
 
Old 03-15-2007   #1 (permalink)
Shadow


 
 

Creating files from Data Table

i have an interesting need and one that i am almost there with but can't get
the last bit.
i am querying the database to get a results set. Within the resultset,
there are multiple rows within a group (in other words, if i perform a
groupby i see that there are multiple rows per group). I want to take the
contents from this and make a new file for each group name and place the
contents of the rows into the file. So in essense i want to create a union
all statement into a file.

Here is what i have thus far
$dt | %{ni -itemType File $_.Item(0) -value $_.Item(1)}

This takes each item and creates the file and then stuffs the contents. So
i have something that works but it tries to create the same file over for the
rows which have identical names.

I have tried this
$dt | ft sqltext -group Column1 | %{ni -itemType File $_.Item(0) -value
$_.Item(1) -whatif}
but since it is using the FT i don't get the contents.
i have also tried
$dt | group column1 | %{ni -Type File $_.Name -value $_.Values}
but that doesn't quite work either.

How can i get the contents of each item to write into the file per group?

My System SpecsSystem Spec
Old 03-15-2007   #2 (permalink)
Shadow


 
 

RE: Creating files from Data Table

I solved this soon after i posted it. I guess persistance kicked in for me
(and the fact that i just had a Mocha with 4 shots of espresso)
$dt | group Column1 | %{ni -type File $_.Name -value ( $_.Group |
%{$_.SQLText})}

"Shadow" wrote:

> i have an interesting need and one that i am almost there with but can't get
> the last bit.
> i am querying the database to get a results set. Within the resultset,
> there are multiple rows within a group (in other words, if i perform a
> groupby i see that there are multiple rows per group). I want to take the
> contents from this and make a new file for each group name and place the
> contents of the rows into the file. So in essense i want to create a union
> all statement into a file.
>
> Here is what i have thus far
> $dt | %{ni -itemType File $_.Item(0) -value $_.Item(1)}
>
> This takes each item and creates the file and then stuffs the contents. So
> i have something that works but it tries to create the same file over for the
> rows which have identical names.
>
> I have tried this
> $dt | ft sqltext -group Column1 | %{ni -itemType File $_.Item(0) -value
> $_.Item(1) -whatif}
> but since it is using the FT i don't get the contents.
> i have also tried
> $dt | group column1 | %{ni -Type File $_.Name -value $_.Values}
> but that doesn't quite work either.
>
> How can i get the contents of each item to write into the file per group?

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
HTA file - display data from DB records in table like ASP - how? VB Script
Goofed up GPT partition table... Data Lost? Vista General
Goofed up GPT partition table... Data Lost? Vista file management
Goofed up GPT partition table... Data Lost? Vista hardware & devices
Adding data to a hash table PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46