[英]Reading excel data from python script for abaqus
I am using abaqus and I want to read values from excel file like(x,y,z) and I want to get get an output for it, in the excel file itself. 我正在使用abaqus,我想从excel文件中读取值(x,y,z),并希望在excel文件本身中获得输出。 Plz guide me I been trying it but I didn't got much.
请Plz指导我我一直在尝试,但是我没有太多。
enter code here
# -*- coding: mbcs -*-
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
from mesh import *
from optimization import *
from job import *
from sketch import *
from visualization import *
from connectorBehavior import *
from xlrd import *
file_location=('C:\Users\Lenovo\Desktop/calling.xlsx')
workbook=xlrd.open_workbook(file_location)
sheet=workbook.sheet_by_index(0)
for col in range(sheet.ncols)
sheet.cell_value(nrow,col)
when I run this script an error pop out invalid file. 当我运行此脚本时,错误弹出无效文件。
I recommend you use xlwings, here's how you interact with an excel file: 我建议您使用xlwings,这是与excel文件进行交互的方式:
#Import xlwings parts
from xlwings import Workbook, Sheet, Range, Chart
#import os
import os
#get workbook direction, I'm supposing it's in same folder than this script!
direction=os.path.join(os.getcwd(),"activo.xlsx")
#if it's not, put it yourself:
#direction="yourPathToFile/yourExcelFile.xls"
#open the workbook
wb = Workbook(direction)
#select the sheet
shname=Sheet(1).name
#from python to excel
pythonVar="I'm writting in excel!"
Range(shname,'A1',wkb=wb).value = pythonVar
#from excel to python
readValue=Range(shname,'A1',wkb=wb).value
print readValue
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.