When saving the data to csv, data.to_csv(\'csv_data\', sep=\',\', encoding=\'utf-8\', header= False, index = False), it creates a blank line at the end of csv f
data.to_csv(\'csv_data\', sep=\',\', encoding=\'utf-8\', header= False, index = False)
A more efficient way is to open the file first, write to that stream, then remove the last newline:
import os with open('csv_data', 'wb') as dst: data.to_csv(wb, sep=',', encoding='utf-8', header= False, index = False) dst.seek(-1, os.SEEK_END) # <---- 1 : len('\n') dst.truncate()