pipe - Combine values from different feed items -
using xpath fetch page managed output after fetching html table
0 content $59,00 1 content $61,00 2 content $1.873,25 3 content $2.460,70 4 content us$1,49
i math on values, (assuming [#] element index):
{ [3] + 50 / ([0] + [1])/2) }
or
{ [4] + 50 / ([0] + [1])/2) }
i don't care item [4].
i'm thinking i'll have first remove currency symbols somehow, find way parse values simple math module. clues?
some context: i've experimented pipes in past (several years ago), combining feeds, not doing math. came pipes today found xpath fetch module, looked interesting, got stuck apparently simple exercise.
here pipe's link can see (clue: not far...) : http://pipes.yahoo.com/pipes/pipe.info?_id=06780ca250e5b107b7c1ef52455996ff
i'm not sure understand question - have large list of values, each element index (from 0 4) before it? or have 10 lines, $ values change each time?
i assume latter case - i.e. table once per html file, , want single number it.
i use this:
... | tr -d '.$' | tr ',\n' '. ' | sed 's/content/c/g' | sed 's/0 c \(.*\) 1 c \(.*\) 2 c \(.*\) 3 c \(.*\) 4 c \(.*\)/\4 + 50\/(\1 + \2)\n/' | bc -l
explanation:
- first remove '$' sign , '.' using `tr -d'
- then transform ',' dot '.', , remove newlines (make single line)
- then shorten "content" "c", make next part shorter
- i use
sed
split fields , take write mathematical expression values - note - have used
cut
well, if i'd have added '+/()' symbols - lastly, take resulting expression , pipe
bc
. have usedpython
well,bc
Comments
Post a Comment