import io


def tab_to_string(tab, withheader=False):
	""" turn table into string with each line seperated by \n """
	# with io.BytesIO() as f_temp: 
	with io.StringIO() as f_temp: 
		tab.write(f_temp, format='ascii.csv', comment=False)
		tabstring = f_temp.getvalue()

	if not withheader:
		# take out header
		tabstring = '\n'.join(tabstring.splitlines()[1:]) + '\n'

	return tabstring