How to concatenate and sort three CSV files in Gnuplot

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I have to plot with Gnuplot the data contained in 3 CSV files.



Commonly, I use the following code to plot from 2 CSV files:



$datablock << EOD
`cat ../Q1a/sim_Q1.csv <(tail -n+8 ../Q1b/sim_Q1.csv | tr '",' ' ' | sort -nk19 )| tail -n+8 | tr '",' ' ' | sort -nk19 > ../Q1a/Q6_ressult.txt`
EOD
set print "|bash -x"
print $datablock
set print


The CSVs are in three different directories.
The data start at row 8, and I must take out the " and , characters, and sort the data by column 19.



I do not know how to extend this code to paste 3 different CSV's doing the same, sort, tail -n+8 and tr commands, and get a final .txt file with the result.










share|improve this question




























    0















    I have to plot with Gnuplot the data contained in 3 CSV files.



    Commonly, I use the following code to plot from 2 CSV files:



    $datablock << EOD
    `cat ../Q1a/sim_Q1.csv <(tail -n+8 ../Q1b/sim_Q1.csv | tr '",' ' ' | sort -nk19 )| tail -n+8 | tr '",' ' ' | sort -nk19 > ../Q1a/Q6_ressult.txt`
    EOD
    set print "|bash -x"
    print $datablock
    set print


    The CSVs are in three different directories.
    The data start at row 8, and I must take out the " and , characters, and sort the data by column 19.



    I do not know how to extend this code to paste 3 different CSV's doing the same, sort, tail -n+8 and tr commands, and get a final .txt file with the result.










    share|improve this question


























      0












      0








      0








      I have to plot with Gnuplot the data contained in 3 CSV files.



      Commonly, I use the following code to plot from 2 CSV files:



      $datablock << EOD
      `cat ../Q1a/sim_Q1.csv <(tail -n+8 ../Q1b/sim_Q1.csv | tr '",' ' ' | sort -nk19 )| tail -n+8 | tr '",' ' ' | sort -nk19 > ../Q1a/Q6_ressult.txt`
      EOD
      set print "|bash -x"
      print $datablock
      set print


      The CSVs are in three different directories.
      The data start at row 8, and I must take out the " and , characters, and sort the data by column 19.



      I do not know how to extend this code to paste 3 different CSV's doing the same, sort, tail -n+8 and tr commands, and get a final .txt file with the result.










      share|improve this question
















      I have to plot with Gnuplot the data contained in 3 CSV files.



      Commonly, I use the following code to plot from 2 CSV files:



      $datablock << EOD
      `cat ../Q1a/sim_Q1.csv <(tail -n+8 ../Q1b/sim_Q1.csv | tr '",' ' ' | sort -nk19 )| tail -n+8 | tr '",' ' ' | sort -nk19 > ../Q1a/Q6_ressult.txt`
      EOD
      set print "|bash -x"
      print $datablock
      set print


      The CSVs are in three different directories.
      The data start at row 8, and I must take out the " and , characters, and sort the data by column 19.



      I do not know how to extend this code to paste 3 different CSV's doing the same, sort, tail -n+8 and tr commands, and get a final .txt file with the result.







      shell gnuplot






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 12 at 12:54







      user1993416

















      asked Feb 10 at 21:06









      user1993416user1993416

      1175




      1175




















          1 Answer
          1






          active

          oldest

          votes


















          1














          I'm not sure how Gnuplot plays into this specifically, but if you're looking for a way to tail multiple files you can do so simply by passing their names on the command line.



          The only gotcha is that tail will separate the outputs with a header for easier human viewing unless you add the -q option:




           -q, --quiet, --silent
          never output headers giving file names



          So as far I can see, you can skip the process substitutions and multiple (re)sorts simply do



          tail -q -n+8 ../Q1a/sim_Q1.csv ../Q1b/sim_Q1.csv ../Q1c/sim_Q1.csv | tr '",' ' ' | sort -nk19





          share|improve this answer























          • Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

            – user1993416
            Feb 11 at 10:11












          • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

            – steeldriver
            Feb 11 at 12:47











          • Thank you. The solution works.

            – user1993416
            Feb 11 at 13:05











          • Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

            – user1993416
            Feb 12 at 11:39












          • I have posted a new question with the paste of the 5 files. Regards.

            – user1993416
            Feb 12 at 12:34










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499820%2fhow-to-concatenate-and-sort-three-csv-files-in-gnuplot%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          I'm not sure how Gnuplot plays into this specifically, but if you're looking for a way to tail multiple files you can do so simply by passing their names on the command line.



          The only gotcha is that tail will separate the outputs with a header for easier human viewing unless you add the -q option:




           -q, --quiet, --silent
          never output headers giving file names



          So as far I can see, you can skip the process substitutions and multiple (re)sorts simply do



          tail -q -n+8 ../Q1a/sim_Q1.csv ../Q1b/sim_Q1.csv ../Q1c/sim_Q1.csv | tr '",' ' ' | sort -nk19





          share|improve this answer























          • Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

            – user1993416
            Feb 11 at 10:11












          • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

            – steeldriver
            Feb 11 at 12:47











          • Thank you. The solution works.

            – user1993416
            Feb 11 at 13:05











          • Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

            – user1993416
            Feb 12 at 11:39












          • I have posted a new question with the paste of the 5 files. Regards.

            – user1993416
            Feb 12 at 12:34















          1














          I'm not sure how Gnuplot plays into this specifically, but if you're looking for a way to tail multiple files you can do so simply by passing their names on the command line.



          The only gotcha is that tail will separate the outputs with a header for easier human viewing unless you add the -q option:




           -q, --quiet, --silent
          never output headers giving file names



          So as far I can see, you can skip the process substitutions and multiple (re)sorts simply do



          tail -q -n+8 ../Q1a/sim_Q1.csv ../Q1b/sim_Q1.csv ../Q1c/sim_Q1.csv | tr '",' ' ' | sort -nk19





          share|improve this answer























          • Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

            – user1993416
            Feb 11 at 10:11












          • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

            – steeldriver
            Feb 11 at 12:47











          • Thank you. The solution works.

            – user1993416
            Feb 11 at 13:05











          • Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

            – user1993416
            Feb 12 at 11:39












          • I have posted a new question with the paste of the 5 files. Regards.

            – user1993416
            Feb 12 at 12:34













          1












          1








          1







          I'm not sure how Gnuplot plays into this specifically, but if you're looking for a way to tail multiple files you can do so simply by passing their names on the command line.



          The only gotcha is that tail will separate the outputs with a header for easier human viewing unless you add the -q option:




           -q, --quiet, --silent
          never output headers giving file names



          So as far I can see, you can skip the process substitutions and multiple (re)sorts simply do



          tail -q -n+8 ../Q1a/sim_Q1.csv ../Q1b/sim_Q1.csv ../Q1c/sim_Q1.csv | tr '",' ' ' | sort -nk19





          share|improve this answer













          I'm not sure how Gnuplot plays into this specifically, but if you're looking for a way to tail multiple files you can do so simply by passing their names on the command line.



          The only gotcha is that tail will separate the outputs with a header for easier human viewing unless you add the -q option:




           -q, --quiet, --silent
          never output headers giving file names



          So as far I can see, you can skip the process substitutions and multiple (re)sorts simply do



          tail -q -n+8 ../Q1a/sim_Q1.csv ../Q1b/sim_Q1.csv ../Q1c/sim_Q1.csv | tr '",' ' ' | sort -nk19






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 11 at 2:13









          steeldriversteeldriver

          36.5k35287




          36.5k35287












          • Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

            – user1993416
            Feb 11 at 10:11












          • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

            – steeldriver
            Feb 11 at 12:47











          • Thank you. The solution works.

            – user1993416
            Feb 11 at 13:05











          • Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

            – user1993416
            Feb 12 at 11:39












          • I have posted a new question with the paste of the 5 files. Regards.

            – user1993416
            Feb 12 at 12:34

















          • Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

            – user1993416
            Feb 11 at 10:11












          • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

            – steeldriver
            Feb 11 at 12:47











          • Thank you. The solution works.

            – user1993416
            Feb 11 at 13:05











          • Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

            – user1993416
            Feb 12 at 11:39












          • I have posted a new question with the paste of the 5 files. Regards.

            – user1993416
            Feb 12 at 12:34
















          Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

          – user1993416
          Feb 11 at 10:11






          Thank you. Your code is simple and works fine. I would like to ask you how could I select a range of rows in the second file, for example from the 8 row to the 470 row. I could use sed -n -e '8,470p' , but I do not know how to change your solution. I think the problem is that I need this range selection in just one of the three files.

          – user1993416
          Feb 11 at 10:11














          @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

          – steeldriver
          Feb 11 at 12:47





          @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3

          – steeldriver
          Feb 11 at 12:47













          Thank you. The solution works.

          – user1993416
          Feb 11 at 13:05





          Thank you. The solution works.

          – user1993416
          Feb 11 at 13:05













          Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

          – user1993416
          Feb 12 at 11:39






          Finally, my results are in 5 files and 2 of them, I have to make the head -n until some row. Can I write something like tail -q -n+8 file1 <(head -n470 file2 <(head -n380 file3)) file4 file5 ?

          – user1993416
          Feb 12 at 11:39














          I have posted a new question with the paste of the 5 files. Regards.

          – user1993416
          Feb 12 at 12:34





          I have posted a new question with the paste of the 5 files. Regards.

          – user1993416
          Feb 12 at 12:34

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f499820%2fhow-to-concatenate-and-sort-three-csv-files-in-gnuplot%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay