remove header and blank line from output file querying a DB

  • The following script retrieves data from a MS Access database correctly.

    I'd like the output file to NOT have the header and blank line at the beginning of the file.

    Is there a way to suppress these lines?


    A second question while I'm asking.   I'm hardcoding the  pipe  delimiter as part of the query.

    Is there options that can be added to have the system put in a pipe delimiter itself while creating the output lines?




    $conn = New-Object Data.Odbc.OdbcConnection

    $conn.ConnectionString= "dsn=GL;"


    $result =(new-Object Data.Odbc.OdbcCommand("select CMPIDE & '|' & CRTNOE & '|' & ENAMEE & '|' & DPTIDE & '|' & SEXCDE from a_table WHERE CMPIDE = 'AE';",$conn)).ExecuteReader()

    $table = new-object "System.Data.DataTable"


    $table | Out-File .\GroupLife-extract.csv


  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • I have never used powershell with MS Access but I would be inclined to use Export-Csv which has -NoTypeInformation and -Delimiter parameters.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply