hi,
i have text file of the form
atom_trace('emo tion_response_l evel(a1, 1.56072)', emotion_respons e_level(a1, 1.56072), [range(49, 50, true), range(0, 49, unknown)]).
and
atom_trace('got o(a1, a3)', goto(a1, a3), [range(1, 51, true), range(0, 1, unknown)]).
i heve to parse this file . Basically what i required is , i want to extract, emotion response level, range , true and . please tell, how i can parse it.
awaiting your reply.
thanks.
Ghazanfar
removed
Mar 14 '07
10 1880 bvdet 2,851
Recognized Expert Moderator Specialist
I guess ghazanfar solved his problem since he has not been back. For those of you interested, here is the code I came up with: -
fname = r'your_file'
-
-
def atomtraceParse(fn):
-
fileList = [x[x.find(")', ")+4:].replace(', aspect', '').strip() for x in open(fn).readlines()]
-
dd = {}
-
cnt = 0
-
for item in fileList:
-
itemList = item.split('), ')
-
a = itemList[0].split('(')
-
a1 = a[1].split(', ')
-
rangeList = [eval(x.strip('[]()').split('(')[1].replace('unknown', 'False').replace('true', 'True')) for x in itemList[1:]]
-
dd['rec'+str(cnt)]=dict(seed=a[0], agent=a1[0], value=float(a1[1]), ranges=[x for x in rangeList])
-
cnt += 1
-
return dd
-
-
dataDict = atomtraceParse(fname)
-
-
keys = dataDict.keys()
-
keys.sort()
-
for key in keys:
-
for item in dataDict[key]:
-
print '%s: %s = %s' % (key, item, dataDict[key][item])
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bob |
last post by:
Hi,
I have a website in a Linux/Apache shared hosting environment and have
been given access to the MySQL server running on the same machine. To
access this database from PHP, I have to call mysql_connect(host,
user, password) where the password is hardcoded into my PHP source
file in clear text.
I see two security problems with this:
|
by: Scott |
last post by:
I am new to perl, and have not found any good examples of parsing to
help me out. I have a text file that I am reading into an array that
has to be parsed out and put into another file. I have not found any
good examples of this. Does anyone know of any?
For example the text file looks like this...
900002 "Test,Test" 1/1/2004 F 21
with tabs inbetween each of the colums of the text file.
|
by: Eric |
last post by:
Assume that disk space is not an issue
(the files will be small < 5k in general for the purpose of storing
preferences)
Assume that transportation to another OS may never occur.
Are there any solid reasons to prefer text files over binary files
files?
|
by: Hugh |
last post by:
Hello,
I am having some problems understanding (most likely), parsing a text
file. I would like to parse a file like:
block1 {
stuff;
...
stuffN;
};
|
by: .Net Sports |
last post by:
In VB.net, I'm trying to do a couple of things in a couple of different
blocks of code. I need to take the first 25 characters of a text file,
then append at the end some ellipses and a MORE link to a webpage where
viewers can read the rest of the article:
This is the first few characters of text from my file.......<a
href="article-to-read.aspx"> MORE </a>
...I also need to do some in file parsing where I start at one known
keyword (START...
| |
by: sonald |
last post by:
Hi,
Can anybody tell me how to change the text delimiter in FastCSV Parser
?
By default the text delimiter is double quotes(")
I want to change it to anything else... say a pipe (|)..
can anyone please tell me how do i go about it?
|
by: thenewuser |
last post by:
Hi all,
I am working on windows 2000 and using php 5.0 and apache 2.0.59.
I am facing a problem while parsing a text file.Actually I am using a pop server for parsing an email.I am downloading new mails from that server using php and parsing the attachments.I want to parse text files as well. BUt when i save the attached .txt file on my machine, "=20" gets appended at the end of every line.
If the file is an xml file, sometimes "=90" gets...
|
by: toton |
last post by:
Hi,
I have some ascii files, which are having some formatted text. I want
to read some section only from the total file.
For that what I am doing is indexing the sections (denoted by .START
in the file) with the location.
And for a particular section I parse only that section.
The file is something like,
.... DATAS
|
by: flyzone |
last post by:
Goodmorning people :)
I have just started to learn this language and i have a logical
problem.
I need to write a program to parse various file of text.
Here two sample:
---------------
trial text bla bla bla bla error
bla bla bla bla bla
bla bla bla on more lines
|
by: python |
last post by:
I'm parsing a text file for a proprietary product that has the following
2 directives:
#include <somefile>
#define <name<value>
Defined constants are referenced via <#name#syntax.
I'm looking for a single text stream that results from processing a file
containing these directives. Even better would be an iterator(?) type
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |