If I understand what you wrote, you want something like this: require'files' process=: 3 :0 row_number=. ":y input=: fread '/home/user/input/filename', row_number ,'.pgm'
NB. insert here, some calculations which define output as a sequence of characters assert. 1=#$output assert. ' ' ={.0#output output fwrite '/home/user/output/filename', row_number ,'.pgm' ) proccess"0(1+i.50) The result here will be a list of length 50, representing the number of bytes written to each of these files (_1 for any case where the write was unsuccessful). -- Raul On Mon, Sep 10, 2012 at 7:41 PM, pascha <amirpasha...@gmail.com> wrote: > > could I put it into simple form: > > I'd like to write a verb that reads and process "each" row of a table (50 x > 8) with the condition that this verb calls for two other verbs (read and > write) which they need a specific path. The problem is that how can I read > this table row by row and number the path's "filenames" based on the > row_number that is processing? > > process=: : 0 > input=: read '/home/user/input/filename', row_number ,'.pgm' > > **some calculations** > > output=: write '/home/user/output/filename', row_number ,'.pgm' > ) > > > > Ric Sherlock wrote: >> >> I'm struggling to understand exactly what you are trying to achieve >> but am assuming it just involves processing a set of files. If so then >> something like this might work. >> >> Create a 2 column table of outfilenames ,. infilenames. It doesn't >> really matter how you do this but for clarity here's an example: >> outpath=: 'path/out/' >> inpath=: 'path/in/' >> outfiles=: ((outpath,'outfile') , ,&'.txt') each 8!:0 ] i.3 >> infiles=: ((inpath,'infile') , ,&'.png') each 8!:0 ] i.3 >> outfiles,.infiles >> ┌─────────────────────┬───────────────────┐ >> │path/out/outfile0.txt│path/in/infile0.png│ >> ├─────────────────────┼───────────────────┤ >> │path/out/outfile1.txt│path/in/infile1.png│ >> ├─────────────────────┼───────────────────┤ >> │path/out/outfile2.txt│path/in/infile2.png│ >> └─────────────────────┴───────────────────┘ >> >> Then you want to process each row of this table. The verb processData >> is a placeholder for whatever processing you need to do to take the >> contents of the infile and produce the contents for the outfile. >> >> (fwrite~ processData@fread)/"1 outfiles,.infiles >> >> This is essentially doing the equivalent of the following for each >> pair of out and in files: >> >> 'out/path/outfile1.txt' (fwrite~ processData@fread) >> 'in/path/infile1.png' >> >> HTH >> >> > -- > View this message in context: > http://old.nabble.com/path-variable-in-loop-tp34413608s24193p34415893.html > Sent from the J Programming mailing list archive at Nabble.com. > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm