Home

LPrun - Output to a CSV file ?

Apologies in advance for novice question , but , we have a requirement to get a daily extract from an SQL database. using LINQPad i've written the query to get the data we need .. this works fine.. next challenge is to be able to run this in a script and output the results to a csv file .. this is where I'm currently struggling .. Using lprun i can produce a file like this :-
[
{
"field 1": value,
"field 2": value,
...
...
},
{
"field 1": value,
"field 2": value,
etc..

or a html file of the first 1000 records .. but I really need a 1 record per line, delimited ( e.g. csv ) file..
Any assistance would be greatly appreciated ..

Comments

  • There are a couple of ways to output to CSV. Both are described here:

    http://www.linqpad.net/lprun.aspx

    Does this help?
  • Thanks for replying Joe .. yeah .. that's where I got to , but couldn't get it to format the output as csv .. probably missing something really obvious.. ( p.s. my SQL is quite weak .. as per my LINQ knowledge ) .. e.g I have a SQL program that basically just does a select staement .. so I'm running ..
    lprun sqlprog.linq > results.txt
    this gives a file in the format above ..
    ..using -format=csv doesn't seem to make any difference .. although -format=html does produce a html format file ..... but only the first 1000 records..
    looked at using the the util method bu t kno sure how to incorporate into my program .. any help would be gratefully received .. thanks

  • I've reproduced the problem.

    As it stands, the CSV mode works for C#/VB/F# queries, but not for SQL queries. I've fixed this for the next beta build, which should be due out in a week or so.

    Thanks for reporting.

    Joe
Sign In or Register to comment.