with biber, how to declare that all citations in a given file are of a given category?

I am using biblatex with Biber. I am using categories to separate citations that belong to different types and to produce different bibliographies accordingly. Let's say I have a.bib file that contains bib records (let's say with labels a1, a2, ...) that all belong to a category c1, and a b.bib file that contains bib records (labels b1, b2, ...) that all belong to category c2. Currently, I write something like this:

\usepackage[citestyle=numeric-comp,backend=biber,defernumbers=true]{biblatex}
\DeclareBibliographyCategory{c1}
\DeclareBibliographyCategory{c2}


Is there an easy way to say: "all bib records in a.bib belong to c1, without listing them all?"

biblatex offers two main solutions to the task of splitting/categorising entries into arbitrary subsets

1. bibliography categories and
2. keywords.

Bibliography categories work on the fly on the document side. You declare categories with \DeclareBibliographyCategory and add entries to categories with \addtocategory in your document. Categories are useful for ad-hoc classification and grouping that may vary from document to document. One great example of categories is How to split bibliography into "works cited" and "works not cited"?, where categories are used to split the bibliography in cited works and those added with \nocite.

Keywords on the other hand are added to the .bib file in the keywords field. They require no further set-up in the document and can be used directly to filter bibliographies with keyword=<keyword> or for general purpose tests with \ifkeyword{<keyword>}{<true>}{<false>}. Since keywords come from the .bib file, they are usually tied to a specific entry and not to a document.

For the most part, categories and keywords can be used in a similar fashion once they are known/defined.

When Biber/BibTeX has processed your .bib file and passes the data on to biblatex in the .bbl there is no information about the data source of each entry. That makes it extremely hard to generate categories from .bib files, since the relevant data is not available any more.

There is, however, a trick to let Biber add different keywords for each .bib file as shown in biblatex: multiple bibliographies categorised by different .bib files.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear]{biblatex}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-primary.bib}
\step[fieldset=keywords, fieldvalue={, primary}, append]
}
\map{
\perdatasource{\jobname-secondary.bib}
\step[fieldset=keywords, fieldvalue={, secondary}, append]
}
}
}

\usepackage{filecontents}
\begin{filecontents}{\jobname-primary.bib}
@BOOK{hectic,
AUTHOR    = {Henry Hectic},
TITLE     = {How Horticulturalists Howl},
PUBLISHER = {Honorary Books: Henage},
YEAR      = {2000}
}
\end{filecontents}
\begin{filecontents}{\jobname-secondary.bib}
@BOOK{flutter,
AUTHOR    = {Frederick Flutter},
TITLE     = {Fraternising with Flowers},
PUBLISHER = {Frippery Pamphlets: Folkestone},
YEAR      = {1995}
}
\end{filecontents}

\begin{document}
Some citations: \cite{hectic}, \cite{flutter}.
\printbibliography[title=Primary Sources, keyword=primary]
\printbibliography[title=Secondary Sources, keyword=secondary]
\end{document}


If you insist on categories, this can be used as a roundabout way to produce categories in the end as follows.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear]{biblatex}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-primary.bib}
\step[fieldset=keywords, fieldvalue={, primary}, append]
}
\map{
\perdatasource{\jobname-secondary.bib}
\step[fieldset=keywords, fieldvalue={, secondary}, append]
}
}
}

\DeclareBibliographyCategory{primary}
\DeclareBibliographyCategory{secondary}

\AtDataInput{%
\ifkeyword{primary}
{}%
\ifkeyword{secondary}
{}%
}

\usepackage{filecontents}
\begin{filecontents}{\jobname-primary.bib}
@BOOK{hectic,
AUTHOR    = {Henry Hectic},
TITLE     = {How Horticulturalists Howl},
PUBLISHER = {Honorary Books: Henage},
YEAR      = {2000}
}
\end{filecontents}
\begin{filecontents}{\jobname-secondary.bib}
@BOOK{flutter,
AUTHOR    = {Frederick Flutter},
TITLE     = {Fraternising with Flowers},
PUBLISHER = {Frippery Pamphlets: Folkestone},
YEAR      = {1995}
}
\end{filecontents}