Пример #1
0
def read_excel(path):
    name, type = path.rsplit('.', maxsplit=1)
    if type == 'csv':
        with open(path, newline='') as f:
            reader = csv.reader(f, delimiter=',')
            data = [line for line in reader]
            return data
    elif type in ['xlsx', 'xls']:
        workbook = xlrd.open_workbook(path)
        sheet1 = workbook.sheet_by_index(0)
        rows = len(sheet1.col_values(0))
        data = [sheet1.row_values(i) for i in range(rows)]
        return data
    else:
        print('{}文件格式不支持'.format(type))
        return -1
Пример #2
0
def read_xlsx(self, path):
    timer = QElapsedTimer()
    timer.start()
    #打开文件
    workbook = xlrd.open_workbook(path)
    #获取sheet
    # sheet_name = workbook.sheet_names()[0]
    # print(sheet_name)
    sheet1 = workbook.sheet_by_index(0)
    # print('Sheet name: %s' % sheet1.name)
    # head = sheet1.row_values(0)
    # self.mode.setHorizontalHeaderLabels(list(head))
    rows = len(sheet1.col_values(0))
    self._data = [sheet1.row_values(i) for i in range(rows)]
    print('init data need %s seconds' % (timer.elapsed() / 1000))
    # print(self._data)
    mode = TableModel(self._data, self.tableview)
    self.tableview.setModel(mode)
    # #根据内容调整表格
    # self.tableview.resizeRowsToContents()
    # self.tableview.resizeColumnsToContents()

    print('input data need %s seconds' % (timer.elapsed() / 1000))
Пример #3
0
# Left to do: SChriftgröße gui, mails leerzeichen, schreiben in excel-sheet Nötig: install xlrd, pandas, sys, tkinter

#Pad herunterladen ( https://ethercalc.org/zw1njrpgh5fw)
import urllib.request
url = "https://ethercalc.org/zw1njrpgh5fw.xlsx"
urllib.request.urlretrieve(url, 'C:/Users/teres/OneDrive/Desktop/Dokumente/Python/Stuttii2.xlsx')

# Excelsheet importieren
import xlrd
import openpyxl
from openpyxl import workbook
from openpyxl import load_workbook
file_location = "C:/Users/teres/OneDrive/Desktop/Dokumente/Python/Stuttii2.xlsx"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)
namensliste = sheet.col_values(0, start_rowx=31, end_rowx=36)
laenge = len(namensliste)
emailliste = sheet.col_values(1, start_rowx=31, end_rowx=36)

# Block für die Vorbereitung der Erinnerungsmails
import sys, smtplib, os
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
from email.utils import formatdate
server = smtplib.SMTP("smtp.de.posteo.de", 587)
senderEmail = "*****@*****.**"

# Tkinter importieren
from tkinter import *
Пример #4
0
def read_xlsx(path):
    workbook = xlrd.open_workbook(path)
    sheet1 = workbook.sheet_by_index(0)
    rows = len(sheet1.col_values(0))
    data = [sheet1.row_values(i) for i in range(rows)]
    return data