简体   繁体   English

如何在python中从excel搜索列值

[英]how to search for a column value from excel in python

Sl No , Task , Date , Hrs Sl No,Task,Date,Hrs

1 ,Proxy bid new flow of accepting all the bids as proxy bid started,12-Nov-12, 8hrs 1,代理出价开始接受所有出价作为代理出价的新流程,12年11月12日,8小时

2 ,Proxy bid new flow of accepting all the bids as proxy bid completed in local machine,14-Nov-12 4hrs 2,接受所有出价作为代理出价的代理出价新流程在本地计算机上完成,12月11日至11月4日

3 ,Proxy bid new flow of accepting all the bids as proxy bid uploaded in test server and then in Live server and testing done,16-Nov-12 ,6hrs 3,接受所有投标作为代理投标的代理投标新流程,先将其上传到测试服务器中,然后再上传到实时服务器中,并完成测试,12月16日至11月6日

This is how my excel sheet looks like , Now I want to create a function in python which will take the input parameter of Date or also may be the Task and will return the Hrs. 这就是我的excel工作表的样子,现在我想在python中创建一个函数,该函数将使用Date的输入参数,或者也可以是Task并将返回Hrs。

Is it possible? 可能吗?

Thanks in advance. 提前致谢。

try with this code. 尝试使用此代码。 suppose f1.csv is the file. 假设f1.csv是文件。

import os

str1 = '"Proxy bid new flow of accepting all the bids as proxy bid started"'

def get_hours(str1):
   cmd1 = 'grep -R '+str1 +' f.csv'
   result = os.popen(cmd1).read()
   hrs = result.split(',')[-1]
   print hrs
   return hrs

get_hours(str1)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 python 如何从一个 excel 工作表列中获取输入搜索字符串并在特定列中搜索其他 excel? - Using python how to take input search string from one excel sheet column and search in other excel on a specific column? Python 3.7 - 来自 excel 的搜索值 - Python 3.7 - search value from excel 搜索列,使用python从excel返回行 - search column, return row from excel using python 如何在python中另一列的字符串值中的数据框中的一列中搜索字符串? - How can i search for a string from one column in a dataframe in a string value in another column in python? 如何有条件地(列中的值)在 python 循环中的另一列中搜索子字符串 - how to conditionally (value in column) search for substrings in another column in python loop 如何使用 python pandas dataframe 从 excel 列中提取特定值 - How to extract specific value from excel column using python pandas dataframe 如何从python中上传的Excel(xls或xlsx)文件中读取每个列值? - How to read each column value from uploaded excel (xls or xlsx) file in python? 如何添加基于每一行的不同值的列,以从另一个数据框中进行excel类型“ INDEX,MATCH,MATCH”搜索? - How to add a column that based on the different value for every row conducts excel type “INDEX, MATCH, MATCH” search from another dataframe? 从excel读取一列并解析为字典键值python - reading a column from excel and parsing into dictionary key value python 从 excel 列中过滤数字和特定值 - python - Filter numeric and specific value from excel column - python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM