Python Forum
python one line file processing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python one line file processing
#1
Hi coders,

I have a file stores alerts, and it only stores alerts generated today, alerts before today have been archived to another files with datastamp.

In this file, one line has one alert. First I need to find alert type A, commands like grep will give me a lot of rows which belongs to type A.
Then I need to find if it has a string named "srcip", if not, I just move on to look a new row, if this row has a string named "srcip", then I need to search string "srcport" and "dstip", and store these three variables.
Now I need to search alerts type B, type B also have a lot of rows, but there is a field called "timestamp", type A's "timestamp" should be a few seconds apart type B's, and if the time apart too much, it's not the same, which shouldn't be correlated.
If A's srcip and srcport and dstip is same with type B's, then it's a bingo, and I need to extract "dstport" from type B alert.

The main question I don't know is how to know which rows have already been processed, and only search for the new rows?
Reply


Messages In This Thread
python one line file processing - by har - Dec-05-2019, 09:16 AM
RE: python one line file processing - by ichabod801 - Dec-05-2019, 03:36 PM
RE: python one line file processing - by har - Dec-06-2019, 01:30 AM
RE: python one line file processing - by DeaD_EyE - Dec-06-2019, 08:16 AM
RE: python one line file processing - by har - Dec-09-2019, 06:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,711 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  Getting last line of each line occurrence in a file tester_V 1 906 Jan-31-2023, 09:29 PM
Last Post: deanhystad
  Writing string to file results in one character per line RB76SFJPsJJDu3bMnwYM 4 1,428 Sep-27-2022, 01:38 PM
Last Post: buran
  Print to a New Line when Appending File DaveG 0 1,247 Mar-30-2022, 04:14 AM
Last Post: DaveG
  Find and delete above a certain line in text file cubangt 12 3,621 Mar-18-2022, 07:49 PM
Last Post: snippsat
  CSV to Text File and write a line in newline atomxkai 4 2,768 Feb-15-2022, 08:06 PM
Last Post: atomxkai
  Python code to read second line from CSV files and create a master CSV file sh1704 1 2,444 Feb-13-2022, 07:13 PM
Last Post: menator01
  mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python ilknurg 3 5,730 Jan-18-2022, 06:25 PM
Last Post: ilknurg
  multi-line CMD in one-line python kucingkembar 5 4,108 Jan-01-2022, 12:45 PM
Last Post: kucingkembar
  writelines only writes one line to file gr3yali3n 2 2,439 Dec-05-2021, 10:02 PM
Last Post: gr3yali3n

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020