title: COPY csv-file in the database
body: <p>I am not familiar with the work of CSV files, so I decided to ask for advice. I work in PostgreSQL</p>
  
  <pre><code>COPY mark(id_p,mark,id_dis,date) 
  FROM 'D:\bd2.csv' DELIMITER ',' CSV HEADER;
  </code></pre>
  
  <p>I have such simple code in which I read the data from a file and then immediately enter it into the table, but when the user enters the data and loads it, he has no idea which ID is in the table (I have in the table two ID) and enters the necessary information. And now I have a BIG QUESTION.</p>
  
  <p>How can I read data from a file, but before that I, so to speak, “process” them to additionally indicate the ID needed to enter the table. I have no idea how to function - do it ......</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION csv_test( csv_name_f TEXT)
  RETURNS void
  LANGUAGE 'plpgsql'
  
  AS $BODY$
  BEGIN
  
  COPY mark(id_p,mark,id_dis,date) 
  FROM 'D:\bd2.csv' DELIMITER ',' CSV HEADER;
  
  END;
  $BODY$;
  </code></pre>
  
  <p>If you have an option how to solve it. You can throw a small example, I will be very grateful.</p>
  
  <p>P.S. I was suggested use a "temporary table" since I haven't worked with it, I can't figure out how to do it ..</p>