import pypyodbc
import csv

conn = pypyodbc.connect("DSN=HOSS_DB")
cur = conn.cursor()

tables = []

cur.execute("select * from sys.tables")

for row in cur.fetchall():
    tables.append(row[0])

for table in tables:
    print(table)

    cur.execute("select * from {}".format(table))

    column_names = []

    for d in cur.description:
        column_names.append(d[0])

#    file = open("{}.csv".format(table), "w", encoding="ISO-8859-1")
    file = open("{}.csv".format(table), "w", encoding="utf-8")
    writer = csv.writer(file)
    writer.writerow(column_names)

    for row in cur.fetchall():
        writer.writerow(row)

    file.close()

import pypyodbc
import csv

conn = pypyodbc.connect("DSN=HOSS_DB")
cur = conn.cursor()

tables = []

cur.execute("select * from sys.tables")

for row in cur.fetchall():
    tables.append(row[0])

for table in tables:
    print(table)

    cur.execute("select * from {}".format(table))

    column_names = []

    for d in cur.description:
        column_names.append(d[0])

#    file = open("{}.csv".format(table), "w", encoding="ISO-8859-1")
    file = open("{}.csv".format(table), "w", encoding="utf-8")
    writer = csv.writer(file, lineterminator='\n')
    writer.writerow(column_names)

    for row in cur.fetchall():
        writer.writerow(row)

    file.close()

Use just newline for file terminator.
Use just newline for file terminator.
  import pypyodbc
  import csv
  
  conn = pypyodbc.connect("DSN=HOSS_DB")
  cur = conn.cursor()
  
  tables = []
  
  cur.execute("select * from sys.tables")
  
  for row in cur.fetchall():
      tables.append(row[0])
  
  for table in tables:
      print(table)
  
      cur.execute("select * from {}".format(table))
  
      column_names = []
  
      for d in cur.description:
          column_names.append(d[0])
  
  #    file = open("{}.csv".format(table), "w", encoding="ISO-8859-1")
      file = open("{}.csv".format(table), "w", encoding="utf-8")
-     writer = csv.writer(file)
+     writer = csv.writer(file, lineterminator='\n')
      writer.writerow(column_names)
  
      for row in cur.fetchall():
          writer.writerow(row)
  
      file.close()
  
Use just newline for file terminator.
## Code Before:
import pypyodbc
import csv

conn = pypyodbc.connect("DSN=HOSS_DB")
cur = conn.cursor()

tables = []

cur.execute("select * from sys.tables")

for row in cur.fetchall():
    tables.append(row[0])

for table in tables:
    print(table)

    cur.execute("select * from {}".format(table))

    column_names = []

    for d in cur.description:
        column_names.append(d[0])

#    file = open("{}.csv".format(table), "w", encoding="ISO-8859-1")
    file = open("{}.csv".format(table), "w", encoding="utf-8")
    writer = csv.writer(file)
    writer.writerow(column_names)

    for row in cur.fetchall():
        writer.writerow(row)

    file.close()

## Instruction:
Use just newline for file terminator.
## Code After:
import pypyodbc
import csv

conn = pypyodbc.connect("DSN=HOSS_DB")
cur = conn.cursor()

tables = []

cur.execute("select * from sys.tables")

for row in cur.fetchall():
    tables.append(row[0])

for table in tables:
    print(table)

    cur.execute("select * from {}".format(table))

    column_names = []

    for d in cur.description:
        column_names.append(d[0])

#    file = open("{}.csv".format(table), "w", encoding="ISO-8859-1")
    file = open("{}.csv".format(table), "w", encoding="utf-8")
    writer = csv.writer(file, lineterminator='\n')
    writer.writerow(column_names)

    for row in cur.fetchall():
        writer.writerow(row)

    file.close()
