Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to fix newline and quotation mark

    Help wanted · · · – – – · · ·
    5
    8
    352
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Andy Light
      Andy Light last edited by

      Hi. I have csv-file with separators by comma. And there are few lines that unlike from others. They divided into new lines by some reason.

      In file:

      "word1","word2
      ","word3
      ","word4
      "
      "nextword1","nextword2
      ","nextword3
      ","nextword4
      "
      

      What I need:

      "word1","word2","word3","word4"
      "nextword1","nextword2","nextword3","nextword4"
      

      Can anyone help me to fix this please?

      Ekopalypse 1 Reply Last reply Reply Quote 1
      • Ekopalypse
        Ekopalypse @Andy Light last edited by Ekopalypse

        @Andy-Light

        without knowing what caused it is hard to tell what needs to be done.
        Did you use View->Show Symbols->Show all characters to see
        what has been inserted?

        Andy Light 1 Reply Last reply Reply Quote 0
        • Andy Light
          Andy Light @Ekopalypse last edited by

          @Ekopalypse all of lines ends with CRLF. But bugged rows ends without quotation mark.

          Here is a normal row:

          "word1","word2","word3","word4"
          

          And here is a bugged row:

          "word1","word2","word3","word4
          

          As you can see, the bugged row doesn’t have quotation mark. Maybe there is a way how to find those rows?

          Ekopalypse 1 Reply Last reply Reply Quote 0
          • Ekopalypse
            Ekopalypse @Andy Light last edited by

            @Andy-Light

            given the example I would say this should do it

            find what: ([^"])\r\n
            replace with: \1

            Andy Light 1 Reply Last reply Reply Quote 3
            • Alan Kilborn
              Alan Kilborn last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • Andy Light
                Andy Light @Ekopalypse last edited by

                @Ekopalypse it works! Wonderful! Thanks :)

                1 Reply Last reply Reply Quote 2
                • Sudeep Tamrakar
                  Sudeep Tamrakar last edited by

                  Thanks, it helps me out.

                  1 Reply Last reply Reply Quote 0
                  • Prahlad-Makwana4145
                    Prahlad-Makwana4145 last edited by

                    Hello, @Andy-Light

                    Please follow below steps :

                    Step 1:- Find (in regular expression mode) (.+)
                    Step 2:- Replace with: "/1"
                    Step 3:- This adds the quotes :

                    "word1"
                    "word2"
                    "word3"
                    "word4"
                    

                    Step 4:- Find (in extended mode): /r/n
                    Step 5:- Replace with (with a space after the comma, not shown): ,
                    Step 6:- This converts the lines into a comma-separated list:
                    "word1", "word2", "word3", "word4"

                    I hope above information will be useful for you.
                    Thank you.

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post
                    Copyright © 2014 NodeBB Forums | Contributors