Reading XST file
Thomas Thomas
thomas at eforms.co.nz
Tue May 2 20:58:17 EDT 2006
Hi All,
I need extract the content of an XST file to dictionary object..
below is content of that file
----------------------------------------------------------------------------------------
from work centre XST
[description XRX_DSCRPT_METADATA]
field_0{
string MetaDataFieldName = "title";
string MetaDataPrompt = "Title";
string MetaDataType = "string";
string MetaDataValue = "Student Letter";
}
field_1{
string MetaDataFieldName = "collectionname";
string MetaDataPrompt = "CollectionName";
string MetaDataType = "string";
string MetaDataValue = "999888777666";
}
field_2{
string MetaDataFieldName = "summary";
string MetaDataPrompt = "Summary";
string MetaDataType = "string";
string MetaDataValue = "newman";
}
[description xrx_dscrpt_metadata]
entry_1{
string MetaDataFieldName = "Job Reference";
string MetaDataPrompt = "Job Reference";
string MetaDataDefaultValue = "";
string MetaDataValue = "jgutbcfrvewf";
}
entry_2{
string MetaDataFieldName = "Price Text";
string MetaDataPrompt = "Price Text";
string MetaDataDefaultValue = "";
string MetaDataValue = "758bf6";
}
---------------------------------------------------------------------------
I want a hash to be build based on the content like resulthash ={1:{"MetaDataFieldName" :"Price Text","MetaDataPrompt":"Price Text","MetaDataDefaultValue" :"","MetaDataValue":"758bf6",}, and so on for all ocuurences..}
I started using file objects ..and was thinking is a better way to approach this scenario
from os.path import *
filename="c:\sxtfile.xst";
if exists(filename):
if isfile(filename):
f = open(filename, "rb")
for line in f.readlines():
print line
else:
print "I cannot see a file of this name"
cheers
-----------------------------------------------------
Thomas Thomas
phone +64 7 855 8478
fax +64 7 855 8871
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060503/8378be5b/attachment.html>
More information about the Python-list
mailing list