There is a daily overnight train from Saint Petersburg, which leaves around 22:00 and arrives in Petrozavodsk around 07:00.