Community
    • Login

    All lines in a file have collapsed into one line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 432 Views
    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.
    • Joep KregtingJ
      Joep Kregting
      last edited by

      My debug info:

      Notepad++ v8.6.5 (64-bit)
      Build time : Mar 29 2024 - 17:04:43
      Path : C:\Program Files\Notepad++\notepad++.exe
      Command Line : “E:\SteamLibrary\steamapps\common\Wartales\Extracted\Impatience overhaul\Output\data.cdb”
      Admin mode : OFF
      Local Conf mode : OFF
      Cloud Config : OFF
      Periodic Backup : ON
      OS Name : Windows 10 Home (64-bit
      OS Version : 22H2
      OS Build : 19045.6332
      Current ANSI codepage : 1252
      Plugins :
      ComparePlugin (2.0.2)
      JSMinNPP (1.2006)
      mimeTools (3.1)
      NppConverter (4.6)
      NppExport (0.4)

      I don’t know if this qualifies as a search/replace question so I didn’t use that template.

      A mod I’m using for a game is out of date so I thought I’d try to update it. I thought the easiest way to do this would be to compare the mod’s data file to the game’s data file but when I opened the mod’s data file I saw that all of the code was smushed into one line.

      In the game’s data file the code looks like this:

      {
      	"sheets": [
      		{
      			"name": "icon",
      			"columns": [
      				{
      					"typeStr": "14",
      					"name": "icon",
      					"opt": true
      				},
      				{
      					"typeStr": "0",
      					"name": "id"
      				},
      				{
      					"typeStr": "1",
      					"name": "text",
      					"opt": true,
      					"kind": "localizable"
      				},
      				{
      					"typeStr": "1",
      					"name": "desc",
      					"opt": true,
      					"kind": "localizable"
      				},
      				{
      					"typeStr": "2",
      					"name": "iconeDone",
      					"editor": {
      						"copyPasteImmutable": true
      					}
      				}
      			],
      

      In the mod’s data file the code looks like this:

      {"sheets": [{"name": "icon", "columns": [{"typeStr": "14", "name": "icon", "opt": true}, {"typeStr": "0", "name": "id"}, {"typeStr": "1", "name": "text", "opt": true, "kind": "localizable"}, {"typeStr": "1", "name": "desc", "opt": true, "kind": "localizable"}, {"typeStr": "2", "name": "iconeDone", "editor": {"copyPasteImmutable": true}}],
      

      I know how to manually change the way the code looks on a small scale but the Game’s data file has 289,028 lines and having to manually change the mod’s data file to match that would take way too long.

      I’ve tried adding new lines by using the replace function by adding new lines after the brackets and curly brackets but that only increased the total amount of lines to around 90,000.

      Wartales replace function example.PNG

      Is there a way of changing the way the code looks in the entire file so it matches the game’s data file?

      If it’s allowed I could possibly add the modded file if it helps.

      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @Joep Kregting
        last edited by

        @Joep-Kregting ,

        With just Notepad++, there isn’t a great way. If you are willing to install a plugin, then I would recommend @Mark-Olson’s JsonTools plugin (to install the plugin, use Plugins > Plugin Admin, checkmark JSON Tools, and click Install).

        Once it’s installed, you can open your mod’s data file (the one that’s flat), and then use Plugins > JsonTools > Pretty-print current JSON file to make it more like the original.

        (I cannot guarantee that the plugin’s pretty-print routine will exactly follow the same rules as the original game file. But if you want to look at them both with the same formatting rules, you can use Pretty-print on the original file, as well, which will make them both have the same consistent formatting.)

        Joep KregtingJ 1 Reply Last reply Reply Quote 3
        • Joep KregtingJ
          Joep Kregting @PeterJones
          last edited by

          @PeterJones

          I’ve already installed a few other plugins, I don’t mind installing more.

          I used the pretty-print option and it looks like it fixed the file. There’s still differences in the total amount of lines of code both files have but that’s most likely because the game’s data file has new content in it.

          The only problem I have now is that it’s taking a very long time to compare the two data files.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Joep Kregting
            last edited by

            @Joep-Kregting said in All lines in a file have collapsed into one line.:

            The only problem I have now is that it’s taking a very long time to compare the two data files.

            From your Debug Info that you shared earlier, it appears you are still using the old ComparePlugin. I would recommend uninstalling that and installing ComparePlus instead – it’s the successor to the original, and is actively maintained. I cannot guarantee it will be more efficient at the comparison, but it wouldn’t hurt.

            Joep KregtingJ 1 Reply Last reply Reply Quote 1
            • Joep KregtingJ
              Joep Kregting @PeterJones
              last edited by

              @PeterJones

              Alright, I’ll try ComparePlus instead. I was already planning to let my computer run the comparison overnight so hopefully ComparePlus is faster.

              1 Reply Last reply Reply Quote 1
              • Mark OlsonM
                Mark Olson
                last edited by

                JsonTools maintainer here.

                The sort_keys setting in JsonTools should be set to True when pretty-printing JSON for comparison.

                This is because the order of keys in a JSON object doesn’t matter: {"foo": 1, "bar": 2} and {"bar": 2, "foo": 1} are the same, but a general-purpose diff tool like ComparePlus doesn’t know that.

                1 Reply Last reply Reply Quote 3
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors