1

I'm trying to manipulate bibtex files using biber in tool mode: given the source file source.bib:

@article{key1,
  group = {A}
}
@article{key2,
  group = {A, B}
}

I need to produce:

@article{key1,
  group = {A},
  keywords = {RG;Group A}
}
@article{key2,
  group = {A, B},
  keywords = {RG;Group A; Group B}
}

I type "biber --tool --configfile=group.conf source.bib" with the configuration file group.conf:

<?xml version="1.0" encoding="UTF-8"?>
<config>
     <sourcemap>
        <maps datatype="bibtex" level="user">
            <map map_overwrite="1">
                <map_step map_field_source="group" map_final="1"/>
                <map_step map_field_set="keywords" map_field_value="RG" map_append="1"/>
            </map>
            <map map_overwrite="1" map_foreach="group">
                <map_step map_field_set="keywords" map_field_value=";Group $MAPLOOP" map_append="1"/>
            </map>
        </maps>
     </sourcemap>
</config>

and I'm getting:

@ARTICLE{key1,
  GROUP    = {A},
  KEYWORDS = {RG;Group $MAPLOOP},
}

@ARTICLE{key2,
  GROUP    = {A, B},
  KEYWORDS = {RG;Group $MAPLOOP},
}

Can someone tell me where I'm doing wrong?

0
1

Too long for a comment, hence posted as an answer.

I can't reproduce your results. I get two differences: 1 - $MAPLOOP does get expanded as advertised; 2 - group fields go missing, I'm not sure why, but I suppose it's because this field is not part of the datamodel.

I could achieve your desired results with the following settings:

souce.bib (with usera instead of group):

@article{key1,
  usera = {A}
}
@article{key2,
  usera = {A, B}
}

group.conf:

<?xml version="1.0" encoding="UTF-8"?>
<config>
     <sourcemap>
        <maps datatype="bibtex">
            <map map_overwrite="1">
                <map_step map_field_source="usera" map_final="1"/>
                <map_step map_field_set="keywords" map_field_value="RG" map_append="1"/>
            </map>
            <map map_overwrite="1" map_foreach="usera">
                <map_step map_field_set="keywords" map_field_value=";Group $MAPLOOP" map_append="1"/>
            </map>
        </maps>
     </sourcemap>
</config>

With biber --tool --configfile=group.conf source.bib this results in source_bibertool.bib:

@ARTICLE{key1,
  KEYWORDS = {RG;Group A},
  USERA = {A},
}

@ARTICLE{key2,
  KEYWORDS = {RG;Group A;Group B},
  USERA = {A, B},
}

So I'm not really sure what's going wrong. Can you report if this small change helps? If not, the only thing I can think of is an out of date version (but that's just a not very imaginative hunch). Which biber version are you using?

3
  • Many thanks! I was using biber 2.1 on a mac (MacTeX 2015). I also have MacTeX 2016 installed, which has biber 2.5. With the version 2.5 everything works, including with the custom field name "group". Jan 22 '18 at 13:17
  • Well, current version on CTAN is 2.10, and with it, without additional definitions, "group" is dropped (as I said, I don't really know why). So, if you plan to use this for a one time job, I suppose it's fine. Otherwise, it is better consider the field choice with care.
    – gusbrs
    Jan 22 '18 at 13:27
  • See discussion in tex.stackexchange.com/a/415013/105447 and tex.stackexchange.com/q/415028/105447 to get an explanation why the group field is dropped.
    – gusbrs
    Feb 13 '18 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.