I am trying to import a csv file in PostgreSQL to a table. The table is set up as here:
My csv file is delimited by commas and I have enclosed text that has commas within speech marks. It has no headers. When I go to upload the data using the commands shown I get the error shown
I think this may have something to do with the first column patientId being set up to automatically generate a sequential number? In my csv the numbers in this column are already sequential.
What do I need to do to get this to upload successfully please.
UPDATE - I have now changed my CSV to have headers and changed the code to only call in certain labelled columns so that is skips appId and auto generates the number as set out in the table:
COPY appointments("patientId", "appt", "staffId", "lungCapacity", "note") FROM '/home/user/VBoxShare/Appointment.csv' WITH HEADER CSV;
I am now getting this ERROR: extra data after last expected column CONTEXT: COPY appointments, line 2: "1,4,18/04/2010,4906475184,5163,," I have checked the CSV and there are no additional characters after the data. What could be causing this error?