[PD] Fastest way to find lines in text file

Christof Ressi christof.ressi at gmx.at
Wed Mar 22 16:41:03 CET 2017


you're right, it's indeed slower, I just tested it. implementing the array traversal in pd leads to many redundant operations, which slow the thing down. but it should be quite easy to implement it as external. if you haven't written externals yet, see it as a challenge :-).

but the thing I'm rather wondering is: 

does it *really* have to be faster than 40ms? what are you trying to do? do you *need* the output in 0 logical time? depending on the situation you might want to spread the computation across multiple audio blocks or if you don't care about determinism, have the file in another instance of pd and communicate with netsend/netreceive (one instance makes a request and the other instance sends the result once the search is finished). 

Christof

> Gesendet: Mittwoch, 22. März 2017 um 12:54 Uhr
> Von: Jack <jack at rybn.org>
> An: "Christof Ressi" <christof.ressi at gmx.at>
> Cc: pd-list at lists.iem.at
> Betreff: Re: Aw: Re: [PD] Fastest way to find lines in text file
>
> Le 21/03/2017 à 22:16, Christof Ressi a écrit :
> >> I need to find every lines of a textfile containing a word.
> > 
> > that sentence is quite ambiguous, hehe. 
> 
> We can talk about interger.
> 
> > so we're talking about integers. I'd load the textfile with [text] and then use [text sequence] to spit out all the lines and copy them to a table with 2 * 2.539.592 elements. looping through the table and finding your words should be straightforward and much faster.
> 
> The problem with this solution (if i am right), you need to store the
> second element somewhere to return the line (e.g. 345594 577427) when
> the first match to your interger (i just need to test on the first element).
> I test it with 345594 (5 lines match to this interger) and [realtime]
> return 200 ms to execute it (with msgfile, it is 40 ms). Even, if you
> don't store the second interger to return the whole line, you need 70 ms
> (with [array get], [drip] from zexy and [route] or [select]).
> Maybe i miss something ?
> ++
> 
> Jack
> 
> 
> 
> > 
> > Christof
> > 
> >> Gesendet: Dienstag, 21. März 2017 um 19:20 Uhr
> >> Von: Jack <jack at rybn.org>
> >> An: pd-list at lists.iem.at
> >> Betreff: Re: [PD] Fastest way to find lines in text file
> >>
> >> The textfile has only two "string" by lines.
> >> Here, 20 lines of the textfile :
> >>
> >> 345594 577427
> >> 345594 567267
> >> 345594 528911
> >> 345594 534435
> >> 345594 523087
> >> 345595 374384
> >> 345595 377303
> >> 345595 380544
> >> 345595 379911
> >> 345595 557020
> >> 345595 552396
> >> 345595 562487
> >> 345595 460842
> >> 345595 428449
> >> 345595 424095
> >> 345596 447676
> >> 345598 579883
> >> 345598 379495
> >> 345598 379039
> >> 345598 380328
> >> ++
> >>
> >> Jack
> >>
> >>
> >> Le 21/03/2017 à 19:14, Jack a écrit :
> >>> Hello,
> >>>
> >>> I need to find every lines of a textfile containing a word.
> >>> The textfile has 2.539.592 lines.
> >>> Now, i am using [msgfile] from zexy because i can find a line, skip a
> >>> line and find again ... until the end of the textfile.
> >>> But, i am wondering if there is an other object (in an other library)
> >>> faster, specialized in this work ?
> >>> Thanx.
> >>> ++
> >>>
> >>> Jack
> >>>
> >>>
> >>> _______________________________________________
> >>> Pd-list at lists.iem.at mailing list
> >>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> >>>
> >>
> >>
> >> _______________________________________________
> >> Pd-list at lists.iem.at mailing list
> >> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
> >>
> 
>



More information about the Pd-list mailing list