Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,880 questions

51,806 answers

573 users

How to create a spreadsheet file (CSV) with two columns in Python

1 Answer

0 votes
import csv

data = {"alex(A2)": "alex@email.com(B2)", "alice(A3)": "alice@email.com(B3)"}

with open('d:\data.csv', 'w') as csv:
    columnsTitle = "name(A1), email(B1)\n"
    csv.write(columnsTitle)

    for key in data.keys():
        name = key
        email = data[key]
        row = name + "," + email + "\n"
        csv.write(row)


'''
run:

data.csv
--------
name(A1), email(B1)
alex(A2),alex@email.com(B2)
alice(A3),alice@email.com(B3)

'''

 



answered Jun 28, 2018 by avibootz
edited Jun 29, 2018 by avibootz

Related questions

1 answer 154 views
1 answer 212 views
1 answer 173 views
1 answer 208 views
1 answer 168 views
...