I have multiple files containing unique ids. How do I write a program in python utilizing regex that will read the files, identify the unique ids and store them as ‘fileName’ and ‘ID’ in a separate variable/dataframe that will be outputed as a csv file? Source: Python..
Category : regex
I am trying to pick out the text that surrounds a certain word, in this case the word "hazard". So for example in this text: Text1: "Not sure about this dog toy. This is a hazard. My dog could chew it up and choke on the pieces" I just want to pick out the sentence: "This ..
I want to replace every line in a textfile with " " which starts with "meshname = " and ends with any letter/number and underscore combination. I used regex’s in CS but I never really understood the different notations in Python. Can you help me with that? Is this the right regex for my problem ..
I have following code, which extracts text between the BusContact tag. But I want to print the text in two lines. In summary, replace ‘|’ symbol with ‘n’. I have used re module. searchstring = ‘<BusContact>kdsfdfskfsdffsdsdf|sdfsdfsdfsdfsdf</BusContact>’ import re contactdetail = re.compile(‘<BusContact>(.*?)</BusContact>’).search(searchstring) buscontactdetail = contactdetail.group(1) print(buscontactdetail) Current output: kdsfdfskfsdffsdsdf|sdfsdfsdfsdfsdf Expected Output: kdsfdfskfsdffsdsdf sdfsdfsdfsdfsdf Source: Python..
I have this program from datetime import datetime class stoc(): def __init__(self, nameprod, categ, um=’Buc’, sold=0): self.nameprod = nameprod self.categ = categ self.um = um self.sold = sold self.dd = {} self.di = {} self.de = {} def enter(self, cant, data=str(datetime.now().strftime(‘%Y%m%d’))): self.cant = cant self.data = data if self.dd.keys(): cheie = max(self.dd.keys()) + 1 else: ..
How to enforce python regex search/find functions to move on to the next character instead of skipping the entire matched group? For example import re s = "a123b4567" re.findall(r"d{2}", s) # match two digits This gives the following as one would normally expect. Note that ’12’ is skipped, so ’23’ won’t match. [’12’, ’45’, ’67’] ..

I have a dataframe like as shown below tdf = pd.DataFrame({‘text_1’:[‘value: 1.25MG – OM – PO/TUBE’, ‘value:2.5 MG – OM – PO/TUBE’,’value: 18 UNITS(S)’,’value: 850 MG – TDS AFTER FOOD – SC (SUBCUTANEOUS)’, ‘value: 75 MG – OM – PO/TUBE’]}) I would like to apply regex and create two columns based on rules given below ..
I am trying to convert a String into proper JSON notation. This string, got some correct indexes (with [idx]), and some incorrect indexes (with dot notation .idx. with these last ones starting by 1, instead of by 0). Is there anyway to "handle" captured groups using python re library or similar? This is what I ..
I am getting below error only when i am trying to access the website via domain name. When i access my website using ip address (by running python manage.py runserver) it doesn’t throw an exception. Please check using below: https://adhocdevices.com/ Please help me in resolving this issue. My urls.py is as below: path(‘category/<int:pk>/’,views.CategoryShow), path(‘about/’,views.about,name=’about’), path(‘contact/’,views.contact,name=’contact’), ..
I search a very long string for a couple of keywords and want to extract the number that is listed after them. My Code below works if the keyword is standing alone and not connected with another word as seen here (temperature/melting) and the second problem is the ° sign after the number. I need ..
Recent Comments