Мой скрипт ниже:
import xlsxwriter
import subprocess
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet('NMOC')
bold = workbook.add_format({'bold': True})
# Write some data headers.
worksheet.write('A1', 'RNC', bold)
worksheet.write('B1', 'CELL', bold)
for line in open('/root/Desktop/Scripting/Update_Table/eaw/test.txt'):
alias = line.rstrip("\n").split(';')
print(alias)
# Start from the first cell. Rows and columns are zero indexed.
row = 1
col = 0
for rnc, cell in (alist):
worksheet.write(row,col, rnc)
worksheet.write(row,col + 1, cell)
row += 1
workbook.close()
Я использую версию Python 3.5.Это ошибка, которую я получаю:
['BSC19', 'TS9001']
['BSC19', 'TS555']
Traceback (most recent call last):
File "test.py", line 53, in <module>
for rnc, cell in (alias):
ValueError: too many values to unpack (expected 2)
Что не так в моем коде?
[root @ nocjobs eaw] # cat test.txt
BSC19;TS9001
BSC19;TS555