栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Extract columns from Excel using Python

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Extract columns from Excel using Python

The

u
means it is a unipre string, it gets put there when you call
str()
.
If you write the string out to a file it wont be there. What you are getting
is 1 row from the column. It’s because you are using
end_rowx=1
it returns a
list with one element.

Try getting the column value lists:

ids = sh.col_values(0, start_rowx=1)english = sh.col_values(1, start_rowx=1)spanish = sh.col_values(2, start_rowx=1)french = sh.col_values(3, start_rowx=1)

and then you can

zip
them into tuple lists:

english_with_IDS = zip(ids, english)spanish_with_IDS = zip(ids, spanish)french_with_IDS = zip(ids, french)

Which are in the form:

("1", "Hello"),("2", "Hi"), ("3", "Bus")

If you want to print the pairs:

for id, word in english_with_IDS:       print id + "=" + word

col_values
returns a list of column values, if you want single values you
can call
sh.cell_value(rowx, cellx)
.



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/372753.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号