Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: / ky.emrah
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram: / ky.emrah
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!PostgreSQL COPY command from csv file problem for array data
I'm working on migrating data from MongoDB to PostgreSQL. I'm using the mongoexport command to export collections into a CSV file, and then I attempt to import the data from the CSV file into a PostgreSQL table using the COPY command.
By default, array fields in the CSV file are formatted as "[""val1"",""val2""]". When I try to execute the COPY command with this CSV file, I'm getting the following error:
ERROR: "[" must introduce explicitly-specified array dimensions.malformed array literal: "["TRT100925T18"]"
ERROR: malformed array literal: "["TRT100925T18"]"
SQL state: 22P02
Detail: "[" must introduce explicitly-specified array dimensions.
Context: COPY sgmk_hazine_tanim, line 2, column isins: "["TRT100925T18"]"
ERROR: "[" must introduce explicitly-specified array dimensions.malformed array literal: "["TRT100925T18"]"
ERROR: malformed array literal: "["TRT100925T18"]"
SQL state: 22P02
Detail: "[" must introduce explicitly-specified array dimensions.
Context: COPY sgmk_hazine_tanim, line 2, column isins: "["TRT100925T18"]"
To resolve this, I manually correct the array format in Notepad++ to {val1,val2}. However, when I run the COPY command again, I receive another error because the commas within the array are interpreted as new fields:
ERROR: extra data after last expected column
CONTEXT: COPY sgmk_hazine_tanim, line 5: "2024-09-24T05:50:00.114Z,2025-03-11T21:00:00.000Z,121,{TRT120325T12,TRT120325T20},121T2,85.640,4"
SQL state: 22P04
ERROR: extra data after last expected column
CONTEXT: COPY sgmk_hazine_tanim, line 5: "2024-09-24T05:50:00.114Z,2025-03-11T21:00:00.000Z,121,{TRT120325T12,TRT120325T20},121T2,85.640,4"
SQL state: 22P04
Here is my table structure:
CREATE TABLE sgmk_hazine_tanim (
id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
last_update timestamp NOT NULL,
matDate date NOT NULL,
section smallint NOT NULL,
isins text[] NOT NULL,
CBRTCode VARCHAR(32) NOT NULL,
presVal VARCHAR(32) NOT NULL,
payRate NUMERIC(8,4)
);
CREATE TABLE sgmk_hazine_tanim (
id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
last_update timestamp NOT NULL,
matDate date NOT NULL,
section smallint NOT NULL,
isins text[] NOT NULL,
CBRTCode VARCHAR(32) NOT NULL,
presVal VARCHAR(32) NOT NULL,
payRate NUMERIC(8,4)
);
The sgmk_hazine_tanim.csv file for the first couple of rows looks like this:
last_update,matDate,section,isins,CBRTCode,presVal,payRate
2024-09-24T05:50:00.114Z,2025-09-09T21:00:00.000Z,111,{TRT100925T18},13T,69.782,
2024-09-Source of the question:
https://stackoverflow.com/questions/7...
Question and source license information:
https://meta.stackexchange.com/help/l...
https://stackoverflow.com/
Информация по комментариям в разработке