In Excel auf eine Reihe zugreifen

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
alpha
User
Beiträge: 195
Registriert: Freitag 23. Mai 2003, 23:24
Wohnort: Ulm

Hallo Pythoncommunity,

ich habe folgendes Problem:
Mit

Code: Alles auswählen

v = MyWorkSheet.Rows(i)
lese ich eine ganze Excelzeile ein. v hat dann dann type 'instance'.
und folgenden Inhalt:
((u'OPC-Item', u'Einheit', u'Beschreibung\ndeutsch / englisch', u'Bemerkungen de
utsch / englisch', u'Beschreibung\ndeutsch', u'Bemerkungen deutsch', u'Beschreib
ung\nenglisch', u'Bemerkungen englisch', u'Beschreibung\nfranz\xf6sisch', u'Beme
rkungen franz\xf6sisch', u'Beschreibung\nspanisch', u'Bemerkungen spanisch', u'B
eschreibung\nxxxxx', u'Bemerkungen xxxxx', None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None, N
one, None, None, None, None, None, None, None, None, None, None, None, None, Non
e, None, None, None, None, None, None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None),)


Jetzt meine Frage. Ich möchte das in einer Liste haben, bekomme das aber nicht hin egal wie ich "v" wandle oder anderen Typen zuweise. Habt ihr einen Tip für mich?

Vielen dank
alpha
Benutzeravatar
gerold
Python-Forum Veteran
Beiträge: 5555
Registriert: Samstag 28. Februar 2004, 22:04
Wohnort: Oberhofen im Inntal (Tirol)
Kontaktdaten:

alpha hat geschrieben:Habt ihr einen Tip für mich?
Hi alpha!

Ja :-)

Code: Alles auswählen

#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-

import os
import win32com.client


filename = os.path.abspath("aaa.xls")
valuelist = []

excel_app = win32com.client.dynamic.Dispatch("Excel.Application")
try:
    excel_workbook = excel_app.Workbooks.Open(filename)
    try:
        excel_sheet = excel_workbook.Worksheets("Tabelle1")
        try:
            for value in excel_sheet.Rows(1).Value[0]:
                if value is not None:
                    valuelist.append(value)
        finally:
            del excel_sheet
    finally:
        excel_workbook.Close()
        del excel_workbook
finally:
    excel_app.Quit()
    del excel_app

print valuelist
mfg
Gerold
:-)
http://halvar.at | Kleiner Bascom AVR Kurs
Wissen hat eine wunderbare Eigenschaft: Es verdoppelt sich, wenn man es teilt.
alpha
User
Beiträge: 195
Registriert: Freitag 23. Mai 2003, 23:24
Wohnort: Ulm

Danke Gerold,

werd ich gleich mal ausprobieren.
alpha
Antworten