-3

I have python list

['Abendgymnasium Wiesbaden', 'Brunhildenstraße 140', '65189', 'Wiesbaden', '+49611315138', '+49611314971', 'poststelle@abendgymnasium.wiesbaden.schulverwaltung.hessen.de', 'http://www.ag-wi.de/']

I want them to be append in csv file like this

column 1: item 1 of list
coumn 2: item 2 of list
column 3: item 3 of list

Ali Umer
  • 13
  • 5

1 Answers1

0

Try this ( here I have used colum header as fields).There can be many other methods to achieve the same such as using NumPy or pandas library

import csv

#field names
fields = ['Name', 'Place', 'Number', 'Teplehone_Number'] # add more according to your data

# data rows of csv file
rows = [['Abendgymnasium Wiesbaden', 'Brunhildenstraße 140', '65189', 'Wiesbaden']] # add more according to your data

with open('output.csv', 'w') as f:

    # using csv.writer method from CSV package
    write = csv.writer(f)

    write.writerow(fields)
    write.writerows(rows)
Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67