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.

1 Answer 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
4
  • 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. Commented Feb 11, 2019 at 10:11
  • @user1993416 probably the simplest modification would be tail -q -n+8 file1 <(head -n 470 file2) file3 Commented Feb 11, 2019 at 12:47
  • 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 ? Commented Feb 12, 2019 at 11:39
  • I have posted a new question with the paste of the 5 files. Regards. Commented Feb 12, 2019 at 12:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .