[Swift-user] mapping a 2 dim array to a directory

Ketan Maheshwari ketancmaheshwari at gmail.com
Tue Jun 21 19:36:05 CDT 2011


That looks cool David. Thanks a lot!

Ketan

On Tue, Jun 21, 2011 at 6:18 PM, David Kelly <davidkelly999 at gmail.com>wrote:

> Hey Ketan,
>
> I ran into something like this recently. I used an external mapper and did
> something like this:
>
> type file;
> file myfiles[][] <ext; exec="mapper.pl">;
>
> foreach farray,i in myfiles {
>    foreach myfile,j in farray {
>       tracef("myfiles[%i][%i] is %s\n", i, j, @filename(myfiles[i][j]));
>    }
> }
>
> The mapper just has to know something about how you want your data
> organized. Here's a simple mapper that should work for your example:
>
> #!/usr/bin/perl -w
> use strict;
>
> my @alphabet = ("a" .. "z");
>
> foreach my $count(0..scalar(@alphabet)-1) {
>    my @files = `find . -name \'$alphabet[$count]*\'`;
>    foreach my $filecount(0..scalar(@files)-1) {
>       print "[$count][$filecount] $files[$filecount]";
>    }
> }
>
> So basically this just uses the find command to print something like this:
>
> [0][0] a_00
> [0][1] a_01
> [0][2] a_02
> [1][0] b_00
>
> I think something like that should do the trick.
>
> David
>
> On Tue, Jun 21, 2011 at 4:59 PM, Ketan Maheshwari <
> ketancmaheshwari at gmail.com> wrote:
>
>> Hello,
>>
>> I am trying to get a 2 dim array to map to a directory with a given
>> pattern as follows:
>>
>> The directory contains files with names as follows:
>>
>> a_00
>> a_01
>> .
>> .
>> a_99
>> b_00
>> b_01
>> .
>> .
>> .
>> z_99
>>
>>
>> The mapped variable amap[i][j] should be mapped in such a way that i
>> should map to the prefix and j should map to the suffix part of the file.
>>
>> For example: amap[2][10] should return the file c_10.
>>
>> In addition the said directory is an output directory and does not exist
>> yet.
>>
>> A one dimensional array mapping exists for this which is as follows:
>>
>> file  dat_files[] < simple_mapper;
>>                               padding = 3,
>>                               location = "output",
>>                               prefix  = @strcat( str_root, "_" ),
>>                               suffix  = ".dat" >;
>>
>> I looked into external mappers but could not figure out how exactly to go
>> for it.
>>
>> Any clues?
>>
>>
>>
>> Regards,
>> Ketan
>>
>>
>> _______________________________________________
>> Swift-user mailing list
>> Swift-user at ci.uchicago.edu
>> http://mail.ci.uchicago.edu/mailman/listinfo/swift-user
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/swift-user/attachments/20110621/23396d75/attachment.html>


More information about the Swift-user mailing list