|
From: walter h. <wh...@bf...> - 2013-04-27 14:36:56
|
Am 27.04.2013 16:26, schrieb seb_kramm:
> On 04/27/2013 05:54 AM, Ethan A Merritt wrote:
>> On Friday, 26 April 2013, seb_kramm wrote:
>>> Currently, when chaining different plot commands in a script, it seems that gnuplot
>>> aborts when encountering a error (unreadable data file, in my case).
>>> Is there any way to tell gnuplot not to abort and to move on to the next 'plot'
>>> command ? I searched the manual but found nothing about error handling.
>>
>> There is no general mechanism for continuing to execute a script after an error.
>
> Thanks, indeed this would be a non trivial thing to adress.
>
>>> The situation is as follows: I have many plots to draw from many computer-generated
>>> data files. The script file is itself generated. Now, some data files are ill formed
>>> or non-existent, due to some experimental error (say, the program that generates the
>>> data crashes).
>>> But I would like to have the plots for all the other datafiles.
>>
>> How about
>>
>> expected_file = "filename"
>> stat = system("wc ".expected_file)
>> if (stat ne "") {
>> plot expected_file
>> }
>>
>> If you want to test for a file that exists but is too short to
>> contain the expected data:
>>
>> stat = system("wc ".expected_file)
>> if (stat ne "" && int(word(stat,1)) > min_size) {
>> plot expected_file
>> }
>
> Woaw, really clever trick, I didn't realize you could call shell commands from within
> gnuplot. I will implement this, but the second version will not apply, as my data
> files don't always have the same number of data points.
> Thank you Ethan.
>
> Sebastien Kramm
>
>
hi,
just in case you simply want to check that you have a filesize > 0
test -s FILE would do the trick.
An other funny trick is to use stat.
stat -c "%s" FILE
It read the file system information instead of scanning the whole file.
just my 2 cents.
re,
wh
|