  Aims: Even the most-precise radial-velocity instruments gather
high-resolution spectra that present systematic errors that a data reduction
pipeline cannot identify and correct for efficiently. In this paper, we aim at
improving the radial-velocity precision of HARPS measurements by cleaning
individual extracted spectra using the wealth of information contained in
spectra time-series.
  Methods: We developed YARARA, a post-processing pipeline designed to clean
high-resolution spectra from instrumental systematics and atmospheric
contamination. Spectra are corrected for: tellurics, interference pattern,
detector stitching, ghosts and fiber B contaminations as well as more advanced
spectral line-by-line corrections. YARARA uses Principal Component Analysis on
spectra time-series with prior information to disentangle contaminations from
real Doppler shifts. We applied YARARA on three systems: HD10700, HD215152 and
HD10180 and compared our results to the HARPS standard Data Reduction Software
and the SERVAL post-processing pipeline.
  Results: On HD10700, we obtain radial-velocity measurements that present a
rms smaller than 1 m/s over the 13 years of the HARPS observations, which is 20
and 10 % better than the HARPS Data Reduction Software and the SERVAL
post-processing pipeline, respectively. We also injected simulated planets on
the data of HD10700 and demonstrated that YARARA does not alter pure Doppler
shifted signals. On HD215152, we demonstrated that the 1-year signal visible in
the periodogram becomes marginal after processing with YARARA and that the
signals of the known planets become more significant. Finally, on HD10180, the
known six exoplanets are well recovered although different orbitals parameters
and planetary masses are provided by the new reduced spectra.
