LPRUN and Powershell and CSV!
Options
I have this working fine in Powershell:
lprun -format=csv E:\Outbox\linq.linq > E:\Outbox\test.csv
The script runs a SQL query and dumps the output to a csv file.
When I open the csv file, though, all the data is in one column. How can I output the data so that it actually pus it into columns?
Thanks.
lprun -format=csv E:\Outbox\linq.linq > E:\Outbox\test.csv
The script runs a SQL query and dumps the output to a csv file.
When I open the csv file, though, all the data is in one column. How can I output the data so that it actually pus it into columns?
Thanks.
Comments
-
I don't think it's possible to understand your problem from your description.
If I run the following with powershell 5 and linqpad 5:PS > "<Query Kind=`"Expression`" />`n`nnew[] { new {col1=`"a`",col2=`"b`"},new {col1=`"c`",col2=`"d`"}}" | sc test.linq
This is the the output I see:
PS > lprun -format=csv test.linq > test.csv
PS > gc test.csvcol1,col2
As you can see there are two columns here.
a,b
c,d
Can you describe exactly what you are doing, what you are expecting to see and what you are seeing. A minimal repro would also help, otherwise it's almost impossible to guess what you are omitting.
-
Hi,
Thanks for the reply. My linq file contains one very simple piece of sql SQL: SELECT CA, CB, CC, CD FROM dbo.SomeTableWithData
When I run it in powershell (as in my first post), the data from all columns is in one column. Looking at your example makes me think I have omitted a step?
-
Dear Aquatarkus,
I had a similar problem. I wanted to process the result of my sql query in powershell.
This is how it works for me:# create file with result of query lprun.exe mySQLQuery.linq > test.json # with powershell convert it into powershell object(s) $linqresult = Get-Content -Raw -Path test.json | ConvertFrom-Json # process results by object foreach ($Obj in $linqresult) { # do something with $Obj }
Of course you can pipe it out to normal csv with$linqresult | ConvertTo-Csv | Set-Content myFile.csv
I'd like to do it out of the box with lprune, but sadly I was not able to do it. The switches for format do not have any effect to my results. So maybe the powershell approach helps you.
Best regards,
Jochen
-
Dear Aquatarkus,
Of course you can pipe it out to normal csv with$linqresult | ConvertTo-Csv | Set-Content myFile.csv
I'd like to do it out of the box with lprune, but sadly I was not able to do it. The switches for format do not have any effect to my results. So maybe the powershell approach helps you.
Best regards,
Jochen