Python Forum
Converting query string as a condition for filter data.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting query string as a condition for filter data.
#1
I make a project where user gives a query string for example " ( (ip.src==10.74.45.110 && ip.dst==239.255.255.255) || ip.proto == 17 ) && eth.addr==6c:dd:30:d6:45:f1)"
where all eth.addr, ip.src, ip.dst and ip.proto are field names, and I want to extract all those packets which satisfy above conditions.
But I'm not sure how to write parser for this, is python have any such split function which can do this?
my data structure looks like
 {packet_number_1,{'field_name1': value 1, 'field_name2': value 2},
  packet_number_2,{'field_name1': value 1, 'field_name2': value 2}
  packet_number_3,{'field_name1': value 1, 'field_name2': value 2}
  packet_number_4,{'field_name1': value 1, 'field_name2': value 2}
  packet_number_5,{'field_name1': value 1, 'field_name2': value 2}
  packet_number_6,{'field_name1': value 1, 'field_name2': value 2}} 
Reply
#2
This is not valid Python data structure. It's set and sets can't have non-hashable dictionaries as elements (not to mention smaller issues as missing commas and names which consist spaces).

Building of filter is usually not that hard but for any possible help one needs to provide valid data structure, query data and expected result.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Alteryx QS-Passing pandas dataframe column inside SQL query where condition sanky1990 0 690 Dec-04-2023, 09:48 PM
Last Post: sanky1990
  Filter data into new dataframe as main dataframe is being populated cubangt 8 922 Oct-23-2023, 12:43 AM
Last Post: cubangt
  python sql query single quote in a string mg24 1 995 Nov-18-2022, 08:01 PM
Last Post: deanhystad
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,304 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Same Data Showing Several Times With Beautifulsoup Query eddywinch82 2 1,204 May-29-2022, 11:46 PM
Last Post: eddywinch82
  Converting '1a2b3c' string to Dictionary PythonNoobLvl1 6 1,781 May-13-2022, 03:44 PM
Last Post: deanhystad
  How to map two data frames based on multiple condition SriRajesh 0 1,448 Oct-27-2021, 02:43 PM
Last Post: SriRajesh
  Need help converting string to int dedesssse 7 2,617 Jul-07-2021, 09:32 PM
Last Post: deanhystad
  Converting data object mbrown009 5 2,718 May-30-2021, 11:35 PM
Last Post: mbrown009
  Beautify dictionary without converting to string. sharoon 6 3,299 Apr-11-2021, 08:32 AM
Last Post: buran

Forum Jump:

User Panel Messages

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