为什么我只从excel表中挑选第一个单元格Python 3

时间:2018-04-15 21:05:05

标签: python excel python-3.x pandas tkinter

该计划的目的是提供网址列表并从whois数据中获取电子邮件

import whois
import xlrd
import tkinter
from tkinter import filedialog
from tkinter import *
import pandas as pd

#excel sheet pull
root = Tk()
root.filename = filedialog.askopenfilename(initialdir = "/",title = "Select file",filetypes = (("xls files","*.xls"),("all files","*.*")))
workbookName = root.filename
workbook = xlrd.open_workbook(workbookName)
sheet = workbook.sheet_by_index(0)

'''
for site in sheet.cell:
    whoisdataset = whois.whois(site)
    for key in whoisdataset:
        if "emails" in key:
            enter code here`if "abuse" not in whoisdataset[key]:
                print (key, whoisdataset[key])
'''

#sheet as matrix
df = pd.read_excel(workbookName)
df.as_matrix()

#Whois email pull
#if you replace "df" with a matrix, it will iterate and work
for website in df:
    whoisdata = whois.whois(website)
    for line in whoisdata:
        if "emails" in line:
            if "abuse" not in whoisdata[line]:
                print (website, ":", line, whoisdata[line])

#excel sheet pull工作,如果我将#whois电子邮件提供给1维矩阵,#whois email pull工作,但#sheet as matrix只给我第一个工作单元,有没有人知道如何让它给我整个第一列作为矩阵?

0 个答案:

没有答案