Historical line data is available on covers.com. For the NBA, individual teams are linked from the
NBA Teams page.
Select the team in question and choose the "Past Results" tab.
Your best bet would probably be to program an HTML scraper/parser. You could then format the data any way you required.