Community

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

    Need to find lines that are missing a comma at the end.

    Help wanted · · · – – – · · ·
    5
    11
    81
    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.
    • Monarchia
      Monarchia last edited by Monarchia

      bbe69063-4468-48ea-ae9a-bbb6767c319a-image.png

      Hello! I have run into an issue regarding a slight error in this file which results in the entire file not functioning as it should, and I believe this is due to a deleted comma in one of the rows. As you can see in the attached image, each line ends with a comma but, considering the size of the file (roughly 5000 lines of about the same length as what is shown), it is practically impossible for me to find the error manually. I tried using Ctrl+F/Ctrl+H to find the missing comma but am not sure how to use it effectively. Does anyone know how to find this error with or without Ctrl+H?

      EDIT: Upon using Ctrl+H to search for missing commas, none were found. I believe there is some other undisclosed issue with one of the lines.

      Alan Kilborn Mark Olson 2 Replies Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Monarchia last edited by Alan Kilborn

        @Monarchia

        Try searching for [^,]$ after setting the Search mode to Regular expression.

        Monarchia 1 Reply Last reply Reply Quote 2
        • Monarchia
          Monarchia @Alan Kilborn last edited by

          @Alan-Kilborn Thank you for your response. I have tried both and neither has come up with anything worth noting… so I suppose the error is not due to the lack of a comma. Do you know of any way to perhaps search for the format of each line and accordingly isolate lines that don’t fit the usual format? I’m not sure if that request is within NP++'s capabilities.

          Alan Kilborn 1 Reply Last reply Reply Quote 0
          • Alan Kilborn
            Alan Kilborn @Monarchia last edited by Alan Kilborn

            @Monarchia

            Hm, well from the sample data we can maybe draw some conclusions…

            You might try a Mark operation using the following regular expression:

            (?-s)^".+?": ".+?",$

            It should turn the background of all lines red that conform to what seems to be your format.

            Note that this is fairly “loose” as I really have no idea what truly constitutes a valid line format that is accepted by whatever tool is using the file.

            Monarchia 1 Reply Last reply Reply Quote 3
            • Monarchia
              Monarchia @Alan Kilborn last edited by

              @Alan-Kilborn
              I used the Mark operation and did not find any matching results (There is a nonzero chance I did it wrong)

              I would like to provide more information about how the data is being utilized but struggle to describe how it is as I am not very experienced in this field. For what it’s worth, the information is being accessed by Minecraft and applied to specific text labels spread out through different areas of the game. Here’s another screenshot with more data that is (hopefully) more useful. Any ideas? Thank you for your help up to this point, by the way.

              094b852f-658a-4191-b28b-a2df93aeeee8-image.png

              PeterJones Alan Kilborn 2 Replies Last reply Reply Quote 0
              • PeterJones
                PeterJones @Monarchia last edited by

                @Monarchia ,

                Your file format looks rather JSON-like. If the simple checks that @Alan-Kilborn has pointed out are not finding anything, you might try installing the JSONTools plugin which (IIRC) can do a syntax check on JSON, and might take you to the line where it’s wrong. If that doesn’t find it, then it’s probably not a syntax error, and it’s instead a data-error: ie, some valid JSON string is something that the minecraft engine cannot handle, hence your problem – but if that’s the case, we won’t be able to help you, because this is not a minecraft-modding forum.

                Monarchia 1 Reply Last reply Reply Quote 3
                • Alan Kilborn
                  Alan Kilborn @Monarchia last edited by

                  @Monarchia

                  Offhand, I can’t see why the marking operation didn’t work for you. Of course, we’re just working from pictures, not actual sample text. Usually the first thing we do is ask for real text. This case seemed so simple, though… :-(

                  1 Reply Last reply Reply Quote 2
                  • Monarchia
                    Monarchia @PeterJones last edited by

                    @PeterJones It is a JSON file, yes. I didn’t insert any characters or information that Minecraft is incapable of handling so I really feel as though it’s something vital that I accidentally deleted. I will install the plugin and see if it helps. Thank you for your assistance.

                    PeterJones 1 Reply Last reply Reply Quote 1
                    • PeterJones
                      PeterJones @Monarchia last edited by

                      @Monarchia ,

                      The other thing you can do, if you have the original version of the JSON file, is to use the ComparePlus plugin and compare the old to the new, and thus see all the changes that were made. That might help you narrow down where the problem is.

                      1 Reply Last reply Reply Quote 2
                      • guy038
                        guy038 last edited by guy038

                        Hello, @monarchia, @alan-kilborn, @peterjones and all,

                        Well, @monarchia, after using the Irfanview sofware with a recognition characters plugin and some minor ajustments, I was able to extract this text from your first image which can be transformed into this functional json block, below :

                        {
                         "narrator.position.object list": "Selected row element %s out of %s",
                         "narration.suggestion.tooltip": "Selected suggestion %d out of %d: %s (%s)",
                         "narration.suggestion": "Selected suggestion %d out of %d: %s",
                         "narration.button": "Button: %s",
                         "narration.button.usage.focused": "Press Enter to activate",
                         "narration.button.usage.hovered": "Left click to activate",
                         "narration.cycle button.usage.focused": "Press Enter to si~tc:~ to %s",
                         "narration.cycle~button.usage.hovered": "Left click to switc:~ to %s",
                         "narration.checkbox": "Checkbox: %s",
                         "narration.checkbox.usage.focused": "Press Enter to toggle",
                         "narration.checkbox.usage.hovered": "Left click to toggle",
                         "narration.recipe": "Reciple for %s",
                         "narration.recipe.usage": "Left click to select",
                         "narration.recipe.usage.miore": "Right click to show miore reclpes",
                         "narration.selection.usage": "Press up and down buttons to nove to another entry",
                         "narration.comqoonent~list.usage": "Press Tab to navigate to next element",
                         "narration.slider.usage.focused": "Press left or right keyboard buttons to change value",
                         "narration.slider.usage.hovered": "Drag slider to change value",
                         "narration.edit~box": "Edit box: %s"
                        }
                        

                        Now, @monarchia, try the following method to get all specific lines which do not have the right format :

                        • Open the Mark dialog ( Ctrl + M )

                        • Untick all box options

                        • SEARCH (?x-s) ^ \h* " .+? " : \x20 " .+ ? " , $ (*SKIP) (*F) | ^ .+

                        • Check the 2 options Bookmark line, and Purge for each search

                        • Select the Regular expression search mode

                        • Move to the very beginning of your json file

                        • Click on the Mark All button

                        • Now, hit the F2 key, repeatedly, to get the different lines which do not satisfy your format !

                        Remark the part \h*, at beginning of the regex, which could explain why the previous @alan-kilborn’s solution found nothing !


                        Running this regex against the json block above, previously copied in a new tab, should obviously mark the lines { and }, as well as the last data line "narration.edit~box": "Edit box: %s" which does not end with a comma character !

                        Best Regards,

                        guy038

                        PS :

                        Alan, in order to mark all lines not ending with a comma char, I suppose that the regex [^,\r\n]$ is a better bet !

                        1 Reply Last reply Reply Quote 3
                        • Mark Olson
                          Mark Olson @Monarchia last edited by

                          @Monarchia
                          Looks like you got this fixed, but just wanted to chime in that JsonTools can indeed find the errors in your JSON file (as PeterJones mentioned), but you can also just turn on linting and then you can parse the JSON with any number of missing commas (as well as various other syntax errors) and pretty-print it as syntactically valid JSON.

                          If your JSON file had a truly preposterous number of such syntax errors (say on the order of hundreds of thousands), the linter would probably use a lot of memory though.

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