[PD] parse textfile

Jaime E Oliver jaime.oliver2 at gmail.com
Mon Nov 16 22:18:43 CET 2015


checkout the [textfile] and [list split] objects.
best,
J



On Nov 16, 2015, at 3:58 PM, Simon Iten <itensimon at gmail.com> wrote:

> hi list,
> 
> i’m trying to parse a textfile and use some numbers as parameters in a patch. unfortunately i can’t change the way the textfile is formatted, since it has to be compatible with another program. the first lines look like this:
> 
> 0    ; field:  0  poti:  0   ser.no.:  1 
> 0    ; field:  0  poti:  1   ser.no.:  2 
> 0    ; field:  0  poti:  2   ser.no.:  3 
> 127  ; field:  0  poti:  3   ser.no.:  4 
> 0    ; field:  0  poti:  4   ser.no.:  5 
> 22   ; field:  0  poti:  5   ser.no.:  6 
> 76   ; field:  0  poti:  6   ser.no.:  7 
> 0    ; field:  0  poti:  7   ser.no.:  8 
> 127  ; field:  0  poti:  8   ser.no.:  9 
> 0    ; field:  0  poti:  9   ser.no.:  10 
> 0    ; field:  0  poti:  10  ser.no.:  11 
> 32   ; field:  0  poti:  11  ser.no.:  12 
> 0    ; field:  1  poti:  0   ser.no.:  13 
> 17   ; field:  1  poti:  1   ser.no.:  14 
> 0    ; field:  1  poti:  2   ser.no.:  15 
> 0    ; field:  1  poti:  3   ser.no.:  16 
> 0    ; field:  1  poti:  4   ser.no.:  17 
> 0    ; field:  1  poti:  5   ser.no.:  18 
> 1    ; field:  1  poti:  6   ser.no.:  19 
> 0    ; field:  1  poti:  7   ser.no.:  20 
> 64   ; field:  1  poti:  8   ser.no.:  21 
> 0    ; field:  1  poti:  9   ser.no.:  22 
> 0    ; field:  1  poti:  10  ser.no.:  23 
> 0    ; field:  1  poti:  11  ser.no.:  24 
> 0    ; field:  2  poti:  0   ser.no.:  25 
> -19   ; field:  2  poti:  1   ser.no.:  26 
> 0    ; field:  2  poti:  2   ser.no.:  27 
> 0    ; field:  2  poti:  3   ser.no.:  28 
> 0    ; field:  2  poti:  4   ser.no.:  29 
> 0    ; field:  2  poti:  5   ser.no.:  30 
> 1    ; field:  2  poti:  6   ser.no.:  31 
> 0    ; field:  2  poti:  7   ser.no.:  32 
> 64   ; field:  2  poti:  8   ser.no.:  33 
> 0    ; field:  2  poti:  9   ser.no.:  34 
> 0    ; field:  2  poti:  10  ser.no.:  35 
> 0    ; field:  2  poti:  11  ser.no.:  36 
> 
> basically i just need the first number of every line since that is the parameter. is there a way to route this based on the ser.no (since that is unique) or can i route the number to a send just by line? (i.e. number from first line goes to [s pitch1] number from 2nd line to [s pitch1_fine])
> 
> when i open the file with [read example.txt cr] i get all the parameters on separate lines, since pd starts a new line for all semicolons and all newlines. so if i could just read every second line i would be fine as well.
> 
> to further complicate things i should also be able to write files in that format… and it should all be in vanilla!
> 
> is this even doable in pd?
> 
> attached is an example preset file
> 
> thanks for any insights and sorry for the questions, i just never really worked with file parsing.
> 
> simon
> 
> <example.txt>
> 
> 
> 
> 
> 
> _______________________________________________
> Pd-list at lists.iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list




More information about the Pd-list mailing list