title: PostgreSQL - ERROR: missing data for column "XX" SQL state: 22P04
body: <p>I am trying to import TXT file into the postgreSQL database table, but I am getting an error:</p>
  
  <p>ERROR: </p>
  
  <blockquote>
    <p>missing data for column "bts_name"
    SQL state: 22P04</p>
  </blockquote>
  
  <p>My code is:</p>
  
  <pre><code>COPY indicadores2g (
    Daily,
    BTS_NAME,
    SITE_CODE
  )
  FROM 'C:\Users\Public\Documents\GEO_2G_CELL.txt' 
  WITH CSV HEADER DELIMITER ' ' NULL AS '' ;
  </code></pre>
  
  <p>I know that the problem is in the txt file. In the txt file the last two line are blank (example), and when I remove them, the SQL run without problem.<a href="https://i.stack.imgur.com/c3ryk.png" rel="nofollow noreferrer">enter image description here</a>
  My problem is I need to import every day. Is there any rule to put in my SQL code to run without problems?</p>
  
  <p>Another way to run without problems is: Open TXT in excel and save as CSV. Can I do this automatically?</p>