TA的每日心情 | 开心 2014-1-11 00:20 |
---|
签到天数: 38 天 [LV.5]常住居民I
|
马上注册,下载丰富资料,享用更多功能,让你轻松玩转阳光石油论坛。
您需要 登录 才可以下载或查看,没有账号?欢迎注册
x
话不多说,先给脚本内容:
from xlrd import open_workbook
excel = open_workbook("aaa20201223.xls")
sheets = excel.sheet_names()
fileFP =open("logresults.dat",'w+')
for ii in range(excel.nsheets):
sheet = excel.sheet_by_index(ii)
###
for row_index in range(1, sheet.nrows):
if ("油水" in sheet.cell(row_index,14).value):
petro = 3
elif ("差" in sheet.cell(row_index,14).value):
petro = 1
elif ("干" in sheet.cell(row_index,14).value):
petro = 5
elif ("可能" in sheet.cell(row_index,14).value):
petro = 6
elif ("油" in sheet.cell(row_index,14).value):
petro = 2
elif ("水" in sheet.cell(row_index,14).value):
petro = 4
else:
petro = 0
fileFP.write(str("%s \t%s \t%s \t%i\n"%(sheet.name, sheet.cell(row_index,2).value, sheet.cell(row_index,3).value, petro)))
fileFP.close()
如果我们有一个叫做“aaa20201223.xls”的测井解释汇总表,其中每一口井设了一个表(sheet),表格格式是固定的,都有一行表头,第三列记录了解释层的顶深,第四列记录了解释层的底深,第十五列记录了测井解释结论。
我们需要形成一个Production Log来加载进Petrel。
这个python脚本,只是几句话,即可实现从excel到Production Log的自动转换。一眨眼之间完成这样的工作,还不会出现读写误差。
|
|