xxxxxxxxxx
if OBJECT_ID('tempdb..#tmp') is not null drop table #tmp
create table #tmp
(
ID nvarchar(100),
Name nvarchar(100)
)
BULK INSERT #tmp FROM 'D:\names.csv'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
TABLOCK
)
GO
select * from #tmp
xxxxxxxxxx
header = [re.sub(' +',' ',i[0][:-1].replace('\n', ' ')) for i in optionsTable[0]]
with open('test.csv', 'w') as fp:
writer = csv.writer(fp, delimiter=',')
writer.writerow(header)
for row in optionsTable:
writer.writerow([i[1] for i in row])
#Credit to https://stackoverflow.com/users/790387/burhan-khalid Burhan Khalid
#On StackOverflow.