473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to get a specific words from the line

01JAN 06:49:30.439 WARNING - Entered Zone - Operator = 5, Body Part = Body, u = 75830967.07, v = 45233540.51, w = 0.00, delta = 3

From the above line how to print Entered zone and delta
Feb 3 '20 #1
3 1446
SioSio
272 256MB
If the input format is always constant, split the input data using "split".
Expand|Select|Wrap|Line Numbers
  1. val = input('')
  2. l = val.split(',')
  3. m = l[0].split('=')
  4. n = l[5].split('=')
  5. x = m[1]
  6. y = n[1]
  7. print(x,y)
  8.  
If there is a line feed code after delta = x, the following code works.
Expand|Select|Wrap|Line Numbers
  1. f = open('filename')
  2. val = f.readline()
  3. while val:
  4.   l = val.split(',')
  5.   m = l[0].split('= ')
  6.   n = l[5].split('= ')
  7.   if ('Entered Zone' in m[0]):
  8.       x = m[1]
  9.       y = n[1]
  10.       print(x,y)
  11.   val = f.readline()
  12. f.close
  13.  
One space after "delta = x" followed by the next data.
Expand|Select|Wrap|Line Numbers
  1. f = open('filename')
  2. val = f.readline()
  3. f.close
  4. val2 = val.replace(' ',',')
  5. word = val2.split(',')
  6. flg1 = False
  7. flg2 = False
  8. enterd = ''
  9. delta = ''
  10. i = 0
  11. for elem in word:
  12.     if word[i] == 'Entered':
  13.         enterd = word[i+5]
  14.         flg1 = True
  15.     if flg1 == True and word[i] == 'delta':
  16.         delta = word[i+2]
  17.         flg2 = True
  18.     if flg1 and flg2:
  19.         print(enterd,delta)
  20.         flg1 = False
  21.         flg2 = False
  22.     i = i + 1
  23.  
Feb 3 '20 #2
01JAN 06:49:30.439 WARNING - Entered Zone - Operator = 5, Body Part = Body, u = 75830967.07, v = 45233540.51, w = 0.00, delta = 3 01JAN 06:49:30.439 WARNING - Entered Zone - Operator = 5, Body Part = Body, u = 75830967.07, v = 45233540.51, w = 0.00, delta = 1 01JAN 06:49:30.439 WARNING - EXITED - Operator = 5, Body Part = Body, u = 75830967.07, v = 45233540.51, w = 0.00, delta = 2 01JAN 06:49:30.439 WARNING - Entered Zone - Operator = 5, Body Part = Body, u = 75830967.07, v = 45233540.51, w = 0.00, delta = 4

FILE consists of those lines i have get the lines containing Entered Zone and print the delta value
Feb 3 '20 #3
SioSio
272 256MB
It look like there is no line break and there is no comma only after delta = x, so it is impossible with the previous post way.
I think that After "delta = x", there will be an operation to separate by "split" with a space.
Feb 3 '20 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Rob Meade | last post by:
Lo all, Ok - I'm adding site search functionality to a database driven website. I have a list of 390 stop/ignore words, having looked at ASPFAQ already I see that the example uses an array,...
2
by: Branden | last post by:
hi guys, i was wondering if it is possible to extract selected words in a field to be put in different fields automatically. Do i have to write the code in vb? This is what im trying to do....
0
by: Brian | last post by:
Hello all.. Been having some more trouble with the hit lines in my Air Hockey game. I have some hit lines drawn (and loaded into an array, Lines) around the borders of my table to repel the...
1
by: Toska | last post by:
Hi Wonder how the should use the Regex members to add markup code to words in a text. Code: -------------------- string words1 = "dog|cat|pig|horse|hippo";
5
by: akelly_image | last post by:
Okay, if anyone could toss me some idea's here, please bare with my noobish questions, I just picked up VB2005 Pro about a week ago. ( no prior VB at all ) Here's my issue.. I'm pulling...
11
by: elrondrules | last post by:
Hi Am pretty new to python and hence this question.. I have file with an output of a process. I need to search this file one line at a time and my pattern is that I am looking for the lines...
1
by: reecevdm | last post by:
Hi, is it possible to have to match a specific word and change the color of that word? What I need to do, is for a content, the color needs to be black. But if a specific word is matched in the...
1
by: sejal17 | last post by:
hello everyone, I have a problem to find a specific words from url.How can we find specific words from url?pls answer me as soon as possible.......
1
by: Marco Langes | last post by:
Hello, first of all: Excuse me for some bad English you might experience during the reading of this. So I made this form with an textarea, people can write a comment in here but I wanted to...
0
by: ramniwas74 | last post by:
i want to find some specific words from a paragraph and print them into a label as suppose i have a paragraph:"madam I am Adam" and now i want to search "madam and Adam" from this parapgraph my code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.