Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2014
    Posts
    2

    Unanswered: Change line endings from CR to CR-LF on csv

    I have some tricky files that won't upload to our API database. Our developer says that they have incorrect line-endings (CR as opposed to CR-LF [\r\n]) which cannot be solved on the code side. This results in an error when attempting to upload.

    I was wondering if there is anyway to convert the line-endings on the csv file or create a new csv file with the same data and different line-endings?

    Any suggestions to solve this issue would be greatly appreciated!

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    This answer is pretty operating system specific. Windows likes CR-LF, Linus uses just LF, and other operating systems use just CR. There are of course programs that are exceptions on each operating system.

    Depending on the Windows version, you might be able to use a simple
    Code:
    c:\>type foo.csv >foo2.csv
    The easy answer for dealing with line-end characters would be a short GAWK script. The exact details of the awk script will vary slightly depending on what formatting changes you need to make, but it ought to be quite simple.

    Please tell us the source and destination operating systems, and if the program that creates the CSV file is well known that would help too.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •