Find the answer to your Linux question:
Results 1 to 3 of 3
Hello everyone. Since none of the other 3 threads found containing CSV match my question, I'm here writing to you with a simple question. I am using a web app ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Jan 2013
    Location
    Argentina
    Posts
    120

    CSV - Are there any accepted special characters?


    Hello everyone. Since none of the other 3 threads found containing CSV match my question, I'm here writing to you with a simple question.

    I am using a web app that lets you import CSV files to create data.

    I have created a file that looks like this:

    Code:
    criteria1;criteria2;criteria3;criteria4
    data1,data2,data3,data4
    data1,data2,data3,data4
    data1,data2,data3,data4
    Now, I'd like to split data 2 into more than one line in the resulting output. Result should look like this:

    Code:
    criteria1;criteria2;criteria3;criteria4
    data1;da
    ta
    2;data3;data4
    data1;da
    ta
    2;data3;data4
    data1;da
    ta
    2;data3;data4
    Is there any special combination of characters to include in the input file so that the output on the website reflects my intention?

    I've already tried
    Code:
    da,"\n",ta,"\n",2;
    and
    Code:
    da"\n"ta"\n",2;
    Thanks in advanced.

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,024
    There is no default CSV processing specification. CSV stands for Comma Separated Values and generally, a reasonable expectation would be, the values will be treated as columns of data separated by commas with rows delineated by new lines. It may be the case that the web app has the ability to do something different and if you indicate what the application is someone may be able to help you with that.

    Otherwise if the app accepts html tags you may be able to format the input this way. i.e.
    Code:
    data1,da<br>ta<br>2,data3,data4

  3. #3
    Just Joined! mrbruno's Avatar
    Join Date
    Jan 2013
    Location
    /MilkyWay/Sol/Earth/USA/NC/Raleigh
    Posts
    63
    As Greg pointed out, there's no one consistent standard for dealing anything except the most simple data. It really depends on what's reading the data. If I were writing the script, I might adopt a convention of requiring embedded newlines to be expressed as "\n" without the quotes:

    Code:
    criteria1;criteria2;criteria3;criteria4
    data1;da\nta\n2;data3;data4
    data1;da\nta\n2;data3;data4
    data1;da\nta\n2;data3;data4
    If you're writing a script to read this, you'll probably have to translate the "\n"s to actual newline characters. You might also need to be able to escape a backslash for times when you really want the backslash as part of the data, even if it's followed by an "n".

    Oh what a tangled web!
    Last edited by mrbruno; 4 Weeks Ago at 11:36 AM. Reason: typo: "double word": "as as"

Posting Permissions

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