Q:

Modiying string input from csv to determine the leading sign

I have csv-output from another program like this:
1.0s,34.56a
3.0s,352.12a
5.0s,1995.34b

The first column contains x-values (the s can be neglected) while the second column contains y-values. Using Gnuplot 5 it is possible to simply plot the values, however, I need to determine the leading sign of each value in the second column (all values followed by a should be positive, all values followed by b should be negative).
While the determination of the sign should be easy like described in this post, I'm struggling to split each y-value dynamically. According to the Gnuplot manual, using a substring should be possible but I can't figure out how to tell the substring to only contain the last value.

A:

To get the last character of a string s, use
s[strlen(s):]

To parse your data file correctly, use the following:
set datafile separator ','
parse(s) = (s[strlen(s):] eq "b" ? -1 : 1) * real(s[:strlen(s)-1])
plot 'data.dat' using 1:(parse(strcol(2)))

