473,324 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to process new line in fields while copying data from a file using COPY command

Hi,In my migration script while I am using mysqldump to dump my MySQL database and PostgreSQL COPY command to copy the data files to PostgreSQL db, I am getting error cause of the newline in the fields

Mysqldump command:
Mysqldump –u username -p --no-create-info
--skip-triggers --skip-comments --fields-terminated-by =,
--lines-terminated-by=\n –TC:\tmp –r UTF8 dbname

PostgreSQL COPY command:

COPY dbname.tablename from
‘c:\tmp\tablename.txt’ WITH DELIMITER ‘,’ CSV
NULL ‘\N’ ;But I get the error-
literal carriage return found in data
hint: use \r to represent carriage return
context: COPY tablename line 52
I checked line 52, it has new line in one of the field data
I know I can postprocess the files that are created by mysqldump, but was wondering is there any way to handle it within the postgreSQL COPY command so it escapes the new line within field data?*
Sep 13 '16 #1
0 1993

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: News | last post by:
Is it possible to delete a file by copying it to the "bit bucket" or "null device"? Back in my youth when I live in VMS-land you could delete a file by copying it to NL: ========== I have...
2
by: Robert Fitzpatrick | last post by:
Does COPY require values for each column even though the database field is not set to NOT NULL? I did a COPY TO first to line up the data and then COPY FROM a tab delimited file. Here are the first...
3
by: Ivan Liu | last post by:
I would like know how I can skip a line while reading a set of input data (from a text file) if the first character of the line is "#". My original code reads: ifstream Infile("data.dat"); ...
4
by: chandru1985 | last post by:
Hi Guys , Can u help me out in Pel Coding as i'm new to perl . Can any one of them say whether it to print a line in a colored way in the output file using Filehandler .. Codin is :::...
1
by: sanchit007 | last post by:
How can i open any file using voice command. Means that i say anything like open internet it perform a task....... How we can do through java programming
1
by: kallem | last post by:
Hi I have one text file generated using SQLServer 2005. While I am importing the text file into one of my PostgreSQL table using "copy" it is giving me the following error: ERROR: invalid...
2
by: aphoorva a | last post by:
how to split line exist in a file using (particular)string(ex., and ,or,etc., ) need of c# code for the above problem statement mine is only working only for seperators thanks aphoorva
1
by: Hegde | last post by:
How can I recurse into multiple directories (in windows) and search for all the strings which starts from a particular name. (ex : all strings starting from "perl_") and copy the whole line to a new...
0
by: gaya3 | last post by:
Hi All, In my java application, i need to search a string (Eg: "Hello") in the list of files in the source directory and i need to copy all the files that matches the search text and copy all...
2
by: animeprogrammer | last post by:
How's it going guys? Can you guys tell me if you know some codes to delete a text in a specific line in a text file. Example: This is line 1 This is line 2 this is line 3 Removing line 2, ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.