title: gnuplot - How can I count the number of entries in a csv file column?
body: <p>I have a gnuplot code which includes a function fitting routine.</p>
  
  <p>This routine is slow when a large number of data points must be fitted. The number of data points in my input file is variable depending on the parameters of some simulations I am running.</p>
  
  <p>I wish to fit only 100 points. Up until now I have been doing this by manually computing the number of entries in my input file and dividing by 100 and using the resulting number as the "every N" command to the fitting command.</p>
  
  <p>More detail:</p>
  
  <p>The fitting command I am using is:</p>
  
  <pre><code>fit f(x) "output.csv" every N using 1:4:9 via a,b
  </code></pre>
  
  <p>Where N = integer_round_down(output_file_length / 100.0) - I calculate this manually on a calculator before replacing the value of N manually in my gnuplot script. (Okay, so dividing by 100, I do that in my head, not on a calculator.)</p>
  
  <p>Is there any way that I can get the number of entries in any of the columns, eg col 1, col 4 or col 9... Then use variables in my script to calculate N without having to edit my script everytime I change my simulation parameters?</p>