title: Remove/Prevent First Blank from Oracle CSV MARKUP output file
body: <p>I am currently writing scripts to output table data to CSV files so that they can be ingested into another platform. I'd much rather use the <code>set markup CSV on quote on;</code> SQL option to generate my output file. as it makes the script much cleaner and a whole lot simpler to write.</p>
  
  <p>The problem, however, is that no matter how hard I try, I cannot seem to find an option that will prevent the output file from starting with a blank line. I need the column headers in the very first line and not in the second line.</p>
  
  <p>The scripts need to run on a Windows Server against an Oracle 12c (12.1.0.2.0) Database, using SQLPLUS to execute the SQL commands and PowerShell/batch as the scripting wrapper.</p>
  
  <p>After searching for some time and trying various options that only seem to have any effect on older approaches to CSV outputs. Eventually, I found the Oracle documentation for the SET command and discovered that things like <code>SET NEWPAGE</code>, <code>SET TRIMSPOOL</code> have no effect when using <code>SET MARK[UP]</code>. </p>
  
  <p>Oracle SET Command documentation is here: <a href="https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqpug/SET-system-variable-summary.html#GUID-0AA910C4-C22A-4A9E-BE13-AAA059CC7919" rel="nofollow noreferrer">https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqpug/SET-system-variable-summary.html#GUID-0AA910C4-C22A-4A9E-BE13-AAA059CC7919</a></p>
  
  <p>Is there a simple way to get rid of or suppress the first line that is blank? I really don't want to have to write further file processing scripts that go and remove the line from the file using PowerShell/Batch. That just seems like a really dumb thing to have to do...</p>
  
  <p>A simplified version of my SQL is below and the output still includes the blank first line.</p>
  
  <pre><code>column thespoolfile new_value thespoolfile
  select 'D:\Temp\outfile-detail-' || TO_CHAR( sysdate, 'YYYYMMDDHH24MI' ) || '.csv' as thespoolfile from dual;
  
  set markup csv on quote on;
  SET FEEDBACK OFF;
  set trimspool on;
  SET HEADSEP off;
  SET SQLBLANKLINES off;
  SET termout OFF;
  spool &amp;thespoolfile;
  set define off;
  select *
    from &lt;table&gt;;
  spool off;
  exit
  </code></pre>