I'm trying to understand filtering an Associative Array the D way. I have the code below (Using while readln cause problem failing on Debian using byLineCopy()). When the byKeyValue().filter evaluates to reduce the number of Keys:Values to only the ones in the filtered header, what is the best way to transform the Pair back to an AA instead of having to run the foreach loop after? Basically if the file has 300 columns and 300 in the full header but only 15 in the filtered header I want the return of rec to only be the 15 in an Associative Array. Thanks :)

    string line;
    string[string][] records;
    while ((line = f.readln()) !is null){
        string[string] record;
auto rec = assocArray(zip(h1.fullHeader, splitter(line,','))) .byKeyValue().filter!(a=>h1.filteredHeader.canFind(a.key));

        foreach(r;rec){
            record[r.key] = r.value;
        }
        records ~= record;
    }

Reply via email to