  POLAR is a compact space-borne detector initially designed to measure the
polarization of hard X-rays emitted from Gamma-Ray Bursts in the energy range
50-500keV. This instrument was launched successfully onboard the Chinese space
laboratory Tiangong-2 (TG-2) on 2016 September 15. After being switched on a
few days later, tens of gigabytes of raw detection data were produced in-orbit
by POLAR and transferred to the ground every day. Before the launch date, a
full pipeline and related software were designed and developed for the purpose
of quickly pre-processing all the raw data from POLAR, which include both
science data and engineering data, then to generate the high level scientific
data products that are suitable for later science analysis. This pipeline has
been successfully applied for use by the POLAR Science Data Center in the
Institute of High Energy Physics (IHEP) after POLAR was launched and switched
on. A detailed introduction to the pipeline and some of the core relevant
algorithms are presented in this paper.
