0

Python(xlrdパッケージ)を使用してExcelシートからデータを抽出しています。元のデータがジャンクデータを取得しているので、それらを削除するのを手伝ってください

[text:uのようなジャンク値を以下のように取得します。

[text:u'NAME'、text:u'JACK']

<CODE>

from xlrd import open_workbook

book = open_workbook('C:/Users/arun/Desktop/EX.xls')
sheet0 = book.sheet_by_index(0)
#sheet1 = book.sheet_by_index(1)

print sheet0.col(0) 
print sheet0.col(2)
print sheet0.col(3)
print sheet0.col(4)
print sheet0.col(5)
print sheet0.col(6)
print sheet0.col(7)
print sheet0.col(8)
print sheet0.col(9)
print sheet0.col(10)
print sheet0.col(12)
print sheet0.col(13)
print sheet0.col(14)
print sheet0.col(15)
print sheet0.col(16)
print sheet0.col(17)
print sheet0.col(18)
print sheet0.col(19)
print sheet0.col(20)
print sheet0.col(21)
print sheet0.col(22)
print sheet0.col(23)
print sheet0.col(24)
print sheet0.col(25)
print sheet0.col(26)
print sheet0.col(27)

</CODE>
4

2 に答える 2

4

Cellあなたの「ジャンク」は、「テキスト」タイプの xlrd のリストのように見えます。つまり、ジャンクではないと思います。xlrd によって作成される通常の戻り値です。列(列0など)の値が必要な場合は、試してください

print sheet0.col_values(0)

https://secure.simplistix.co.uk/svn/xlrd/trunk/xlrd/doc/xlrd.html#sheet.Sheet.col_values-methodを参照してください。

于 2013-03-21T11:26:15.623 に答える
1

str(sheet0.col(0)) を使用すると、 text:u 出力がドロップされることがわかりました。

于 2014-06-24T18:39:46.157 に答える