Exporting string to csv keeping commas and new lines

Hi there,
I am exporting string to csv and have been removeing new lines and commas like so
thing.toString().replace(/\n/g, '').replace(',','') ;
how can I do this iwthout losing the line breaks and commas? I can't have them in atm because messes up the csv.

JSON is for 'transfering' information that can be reassembled into number, string, array, object, etc. format afterwards.
Excel can import CSV but it might not understand the complexity of the information. Tyically what you would do is serialize complex information with JSON, recieve it on the other side (wherever that might be) and then deserialize it. After you deserialize it using JSONs abilities to turn your information back into what is was (numbers, strings, arrays and object) it is up to you how you restructure the data for the format you choose.
Your original intent of preserving CSV is best for Excel or OpenOffice Calc. You didn't mention your intent. JSON would package those (CRLF) \n's for you.

Similar Messages

  • File sender  - carriage return and new line as endseparator

    Hi All,
    I'm stumbled with a problem to set carriage return and newline character as the endseparator (record delimiter)
    Scenario: The input file PI is receiving has got few fields which has text in it and the content in this text has got newline characters. So to identify record separator, at  the end of each record the combination of carriage return and new line is added.
    In file sender content conversion I've set the folllowing parameters to achieve this:
    Row.fieldSeparator :   ,  (comma)
    Row.endSeparator  :  '0x0D''0x0A'
    Problem: In my sample input file, the first row has a text field with a newline character. When executed PI is splitting the record at the newline character in the text field (instead of combination of carriagereturn and newline which is set in the endSeparator paramter).
    Pls advice on how to resolve this .
    Happy Holidays!!
    amar

    Rajesh..Thanks for your quick response
    I'm trying with the actual file being provided by the trading partner. I did not generate the file nor changed the file..
    Before identifying the combination of carraige return and new line, the adapter is splitting the record when encountered with new line character within one of the text fields.
    As you said it worked for you, you do have new line characters within fields in a record?..pls throw some light..let me know for any information..
    Thank you
    amar--

  • NEW CELL and NEW LINE

    Hi,
    I am not clear about NEW CELL and NEW LINE in The Main window -> Table -> Footer -> Output options -> Output Table.  Could any one help in explaining exactly what is the purpose of it.
    Thanks
    Ram

    when you are placing a text element, you need to specify whether you want this text element to be displayed in the next cell of the table. If the text element is to be displayed in the next line then you will have to check that as well. So, if you are displaying a list of fields in a row format then for the first field, you check both line and cell and for the rest of the fields you check just the cell.
    Regards,
    Ravi
    Note - Please mark all the helpful answers

  • B2CBasket- Sales Order  How to add Vendor partner and new line item of SO

    Hi,
    I want to add the following BEFORE the sales order creation process starts:
    Add a VENDOR partner
    Add a new line item to ORDERADM_I
    I suspect in BADI CRM_ISA_BASKET_ITEMS and CRM_ISA_BASKET_HEAD. I have user 'HEAD' to add extension fields but cant figure the creation of NEW partners and NEW line item.
    regards,
    Dave

    Thank you for feedback Shantoor,
    The CRM_ORDER_MAINTAIN need not be called as this FM is called immediately following almost all of the CRM_ISA_* BADI's.
    For clarification I just want to expand on the solution..
    In all of these BADI's SAP uses the CT_INPUT_FIELDS parameter. This is where you should enter WHICH fields you have made changes to in the exit. CRM_ORDER_MAINTAIN uses the same parameter.
    However the challenge is .. WHAT do you enter in the CT_INPUT_FIELDS. This is where you have to follow a strategy. I yused the following:
    1. Looked where the structure was used in programs/class to see how SAP used it
    2. Set breakpoints at the call of the BADI. Check what CT_INPUT_FIELDS content is (SAP uses same technique)and try and replicate for your new entries.
    I hope this helps those that, like me, battled a bit with the use of these BADI's.

  • How to provide space and new line to the text in AI Script

    how to provide space and new line to the text in AI Script

    ?? can you explain better, can you at least add another sentence?
    space
    var mySpace = " ";
    new line
    var newLine = "\n";

  • Having problems PrintWriter and new lines in a string

    I apologise if this topic is in the wrong place, but this is my first time asking on these forums.
    At the moment I have a window with an output text area which I want to store the contents of into a file. I use getText() to store the contents to a string, and then write the string to a file using a BufferedWriter. the code is as follows:
    BufferedWriter out = new BufferedWriter(new FileWriter(file));
    String contents = output.getText();
    out.write(contents);
    out.close();The file-name is specified by a FileChooser. All of this works fine, and the text is actually written to the file ok, except that there are no line breaks in it (it's just one continual line of text). I have tried the same process using a string containing "test\ntest" to see if it is just a problem getting the contents of the text area, however it still gives me the same problem.
    Any help on this would be much appreciated.

    Take a look at PrintWriter.
    o See if you can wrap it around a BufferedWriter. (It
    may alrady BE one.)
    o Use it's .println(...) method.That'll still make it appear as one line though. The one-and-only "line" will have the correct platform-specific line terminator (\r\n I suppose), but the string he is writing has embedded \n characters in it, which he is expecting to show up as new lines.
    The OP needs to realize that there really aren't any such thing as "lines". It's all up to the software rendering the text to treat "newline" characters/sequences special. If you were to open that file with a different tool (not Notepad, which only recognizes \r\n as newline sequences), it may display it the way you are expecting.
    Or, you'll have to parse the text and convert it to the proper newline sequences before you write it to the file.

  • Tab And New Line in XML data

    I have a formatted text which I store as a text node. By default the new line char's are converted into white spaces. I read elsewhere on this forum, that we should use the charecter entity reference equivalent &#A; for new line. I did not understand this idea clearly, so I tried this out:
    In my formatted string, I replaced all instances of '\n' with '&#A;'. I create my text node as follows:
    script.replaceAll("\n","&#A;");
    scriptElement = document.createTextNode(script);
    As expected when the XML is written the &#A10; is further encoded into "&#A10". And when I read back my XML from the parser, I get my string back with all the "&#A10;". I again need to do a replace all to get the new line charecters back.
    My question is : Is there any other standard solution to this problem or the bottom line is to replace the new line and tabs with "MUMBOJUMBO" or a standard charecter entity ref and look for the same while reading back.
    Is there anyway I could tell my XMLwriter to convert '\n' into "&#A;" and get back '\n' when I parse the XML?

    by default, all white spaces collapse: http://www.w3.org/TR/xsl/slice7.html#white-space-collapse
    you can use xml:space="preserve" in your XML elements (tags) or
    you can use <fo:block white-space-collapse="false" linefeed-treatment="preserve"> in XSL if you use XSL to format the XML.

  • Problem with CDATA and new line character

    I parse a xml document with org.w3c.dom, the document contain a CDATA section in which there are more lines of text, each line is terminated with the new line character (\n).
    Example:
    <nota>
    <[CDATA[
    first line
    second line
    third line
    ]]>
    </nota>
    When a parse this node:
    Text txt_nota=(Text)elm_nota.getFirstChild();
    String nota=txt_nota.getData();
    the value returned is one string with no new line characters, example:
    "first linesecond linethird line"
    what's wrong?

    Because i use the string nota into a jsp page and i print the string nota into a textarea and the text is with no newline, example:
    <textarea name="nota" rows="4" cols="60"><%= nota %></textarea>
    the text into textarea is:
    first linesecond linethird line
    but i want that the text displayed into textarea is equal the text into the CDATA section:
    first line
    second line
    third line

  • Enter Text in Multi Line TextBox and New Lines

    Hi Guys,
    I have a form that takes a users input and saves to an access
    database.
    The data is in turn drawn by a recordset and displayed on an
    ASP page using VBS.
    The form that takes the info has 1 textbox thats multi line
    and I want it to be a simple input box except when the user adds a
    line break by hitting return I want this to be reflected when the
    record is drawn to the detais page..
    Just now no matter how many times I hit return key when
    typing in the multi line text box and add paragraphs or simple
    sentances they all come out with no line breaks on the page when
    shown???
    Do I have to make my own rich text box editor? or is there
    something Im missing?
    Thanks in advance for any thoughts.
    Tag

    Tag2007 wrote:
    > Thanks Im on the site now and dont see the lite
    version?? Do you have a link to it please..
    InterAKT was acquired by Adobe in September and most of its
    products
    were discontinued. The full version of KTML is now part of
    the
    Kollection suite.
    The solution to your problem is very simple, though. I'm
    sorry I can't
    give you the exact coding, because I haven't used ASP for
    many years.
    However, all that you need to do is to create a function that
    searches a
    string for new line characters and replaces them with
    <br> (or <br />
    for XHTML).
    PHP has a built-in function (nl2br()) to do this, but in ASP
    you need to
    search for the new line character code.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • 500k profile after disruption and new line install...

    Hello,
    Status: 
    I have an open fault logged with BT;  
    Phone line ok but broadband speed low, profile appears stuck at 500k.
    History: sporadic BBand connection and noisy phone line followed by outright failure of both.
    Engineers visited and confirmed line between street and master socket probably corroded - they put it on leg+leg to get it working while we waited for a new physical line to be installed.
    Pavement was dug up, new armoured cable run from street to house, and a proper master socket fitted (NT5 ? but no inbuilt ADSL filter).
    In effort to ensure low noise, ALL other sockets in the property disconnected.
    Digital phone (3 handsets off a single powered base) are run off the master socket using a filter.
    Router is business hub - 2700hgv; f/w 6.1.1.48.1-enh.tm ,  h/w 2701-100589-005 .
    Hub is connected to same master socket as phone (as it's the only socket now connected to the new line).
    New line was installed approx 18 days ago.
    Speed tests (speedtest.net) repeatedly show download of 480kbps, upload around 620kbps.
    No change since new line was installed and all but the master socket decomissioned.
    I use wireless to the router but also repeated tests with a Cat6 copper RJ45 cable and got same results.
    Have taken all wireless devices offline and removed electrical items near phone line power supply and cable path to reduce potential noise and repeated tests.
    I left the router on for two weeks and no increase in broadband speed.
    I rebooted it twice this weekend to see whether it picked up a different profile - but no change.
    BT speedtester repeatedly indicates a profile of 500k (full results further down).
    Last year I had speeds about 512k on a DrayTek router before switching to the 2700HGV. The change to the BT hub upped the download speed to around 1Mbps, which made a huge difference.
    I know I am "a long way from the exchange" but I've had 1Mbps last year and now have a new line into my property, so not much left that I can do to improve the situation.
    I'd like to know what can be done to get me at least 1Mb download again.
    I have an engineer visit due tomorrow but I believe that will be purely to finish putting paving slabs back over the armoured cable that's been installed (i.e. OpenReach dig team rather than line engineers).
    After those slabs are done, I expect the fault will be closed but I'll still have a 500k profile and will need to raise a new fault all over again - that fault was opened 5 weeks ago.
    Results of speedtester.bt.com run just now (1pm Sun 13th March 2011):
    Download speed achieved during the test was - 363 Kbps
     For your connection, the acceptable range of speeds is 100-500 Kbps.
     Additional Information:
     Your DSL Connection Rate :576 Kbps(DOWN-STREAM), 777 Kbps(UP-STREAM)
     IP Profile for your line is - 500 Kbps
    The throughput of Best Efforts (BE) classes achieved during the test is - 2.46:14.86:82.95 (SBE:NBEBE)
    Upload speed achieved during the test was - 638 Kbps
     Additional Information:
     Upstream Rate IP profile on your line is - 777 Kbps
    Router web interface shows:
    Rate:
    576 kbs
    778 kbs
    Max Rate:
    2621 kbs
    784 kbs
    Noise Margin:
    16.7 dB
    7.0 dB
    Attenuation:
    62.8 dB
    35.8 dB
    Output Power:
    16.1 dBm
    12.4 dBm
    Protocol:
    G.DMT2 Annex A
    Channel:
    Interleaved
    DSLAM Vendor Information
    Country: {46336} Vendor: {IFTN} Specific: {48753 }
    ATM PVC:
    0/38
    Rate Cap:
    2621 kbs
    Attenuation @ 300kHz:
    62.8 dB
    Uncanceled Echo:
    -14.8 dB
    Ok
    VCXO Frequency Offset:
    -2.0 ppm
    Ok
    Final Receive Gain:
    34.5 dB
    Ok
    Impulse Noise Comp. Tones:
    0
    Ok
    Excessive Impulse Noise:
    0
    Ok
    I hope that's the information that someone might need to help me at least get 1Mbps back on my line.
    Regards,
    BK

    Hi Bk1
    Welcome to the Community.
    Send me an email to the link in the about me section of my profile.
    I can have this looked into for you further.
    Cheers
    Stuart
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • PHP MYSQL and DW Question: Invalid characters and new lines entry/viewing

    Hello all,
    I have followed David Powers' two php/dw/mysql books and I've
    set up PHP
    pages that insert, edit, delete, etc. listings. Everything
    works fine
    except for invalid characters being inserted into the
    database, and then
    displaying with a question mark in firefox.
    Is there a trick to cleaning up the data that a user may
    paste into a
    textbox on a web page for insertion in the database before
    the data is
    inserted or as it is inserted? Em dashes, en dashes, 'curly
    quotes' etc.
    are giving me problems.
    Also, when I enter new lines into the php page while I'm
    typing out
    information for a record, these new lines are not being
    displayed either
    in the database (using phpmyadmin to view) or on the
    resulting details
    pages, even though I'm using nl2br, etc. Is there a way to
    make this
    work reliably?
    Thank you for any help you may give me!
    -John

    Hello all,
    I have followed David Powers' two php/dw/mysql books and I've
    set up PHP
    pages that insert, edit, delete, etc. listings. Everything
    works fine
    except for invalid characters being inserted into the
    database, and then
    displaying with a question mark in firefox.
    Is there a trick to cleaning up the data that a user may
    paste into a
    textbox on a web page for insertion in the database before
    the data is
    inserted or as it is inserted? Em dashes, en dashes, 'curly
    quotes' etc.
    are giving me problems.
    Also, when I enter new lines into the php page while I'm
    typing out
    information for a record, these new lines are not being
    displayed either
    in the database (using phpmyadmin to view) or on the
    resulting details
    pages, even though I'm using nl2br, etc. Is there a way to
    make this
    work reliably?
    Thank you for any help you may give me!
    -John

  • Missing white apce and new lines in pdf report output

    Ive set up an XSL template to organize the output of a query. The output is missing the new lines and whitespace. I have to believe this is due to the template since the same output viewed in a form is correct. In another thread I have seen that "* {white-space: pre}" is required. Can anyone elaborate on this?

    OK, thanks. I must say I've found getting my feet wet with SQL Developer quite a frustrating exercise. I've been using Toad for the last 7+ years and having recently migrated my desktop from Windows to Linux I needed to find a replacement (yes I know about VMWare, Wine, etc but I want to get away from Windows completely if possible).
    SQL Developer is a good start, but IMO there are still plenty of rough edges that need knocking off. Maybe I've been spoilt by Toad - and in particular the Toad development team through their support on the mailing lists, but I don't see the same level of support here by the Oracle development team.
    Anyway, enough grumbling. Back to work :-)

  • Vim and new lines

    I just switched to Arch, so hi guys!
    I'm using Vim to write a c program for school. The program is supposed to simply output a single rot13'd word, followed by a newline. So I did:
    fprintf(output, "%s\n", result);
    When I opened up the output file though, Vim didn't show a newline. I had to use two '\n' characters to get one line to show up. Exploring around, I found out that when the 'eol' option is set (and it is), vim automatically adds a new line to the file. I'm thinking that this means that Vim will ignore an ending '\n' that I output (replacing it with it's autogenerated one, or maybe it doesn't autogenerate a newline if there already is one?), but it will in fact show up in Visual Studio or whatever my professor uses to run our programs. Is this a safe assumption?

    Trent wrote:What do you mean by "Vim didn't show a newline"?  If you mean there was no blank line at the end of the file, that's expected, given the code.
    Well, I guess I'm used to editors (the text editor in Visual Studio, for example) where the output of my command would look like
    somestring
    <blank line>
    in the editor. Which, as I've been reading on google, is horribly wrong . The whole issue seems rather needlessly complicated. Anyhow, thanks for the cat tip peasantoid, that will help my peace of mind!
    Last edited by nmccrina (2009-10-25 01:45:33)

  • LineBreakMeasurer  and new lines?

    With LineBreakMeasurer I managed to break text into pieces before printing it. But my problem is that new lines made in the text disapear? How could I print them to? This is my code:
            Font font = new Font("Arial", Font.PLAIN, 18);
            float xo = (float)pageFormat.getImageableX();
            float yo = (float)pageFormat.getImageableY();
            as = new AttributedString(txtToPrint);
            aci = as.getIterator();
            LineBreakMeasurer measurer = new LineBreakMeasurer(aci, pg.getFontRenderContext());
            float wrappingWidth = (float)pageFormat.getImageableWidth();
            while (measurer.getPosition() < aci.getEndIndex() )
                String printLine = txtToPrint.substring(measurer.getPosition(), measurer.nextOffset(wrappingWidth) );
                measurer.setPosition(measurer.nextOffset(wrappingWidth));
                pg.drawString(printLine, xo, y + yo);
                y += font.getSize();
            }

    lol... nobody has ever printed txt with severeal new lines?

  • Newbie: BW Export to Excel/CSV file destination and file name

    Is it possible to control where the export of a BW web query is sent by appending the url with some tag voodoo? Also, can I create the file name of the exported file? I figured out how to kick off the export process, but haven't found any code to control the export destination or file name. I wish to skip over the save dialog and write the file to a specific location.

    Hello John,
    BW provides several ways to export data. Please look into Open Hub for example.
    Other options include Information Broadcasting in SAP NetWeaver '04 or MDX, XML Webservices, or OLAP BAPI.
    Regards,
    Marc
    SAP NetWeaver RIG, US BI

Maybe you are looking for

  • ITunes won't start after reinstalls and iPhone problems

    last time I think I clicked Never Register on iTunes after plugging my iphone,downloaded some podcasts to my phone,everything seems alright before that,but then my iphone won't sync properly with itunes... iTunes keeps saying Syncing Iphone (sometime

  • Server Socket Help!

    Hello! I have a problem regarding server socket, i wrote a simple server socket program which would accept a socket then write through the DataOutputStream, using writeByte and read through the DataInputStream using readUnsignedByte. My server socket

  • WAD - Role Menu

    Hi I can not see the role menu in WAD BI 7.0 nor BI 7.1? Does it mean we can not set the role menu anymore?

  • How to design 8x2 Table in webdynpro ?

    Hi, I have given a task of creating 8x2 (8 rows x 2 columns) table where top row should be filled with green/blue color for titlw purposes. I tried doing it without any luck. Please help me to design this table. Table can be any rows or any columns b

  • Preview signature crossed out

    I have been trying to fill out a number of PDFs with Apple Preview on my Mac Mini OS X Version 10.9.2, however the signature fields always have to diagonal lines, crossing out the signature field. When I print the PDF, the signature field still has t