how to debounce button raspi? - python

Permisi, saya mau tanya, saya baru belajar cara program raspi dengan python, kenapa ya ketika button saya tekan = relay on tpi ketika saya tekan lagi relaynya engga off. Rencananya saya ingin menggunakan debounce button untuk mengkontrol relay dan menggunakan fungsi untuk menggabungkan beberapa kode.[enter image description here](https://i.stack.imgur.com/q2Y6A.png)
semoga bisa terjawab

Related

change to uppercase if character before is an underscore

I have a string
inputstring = "ini adalah salah satu theme park yang terkenal yaitu __u__n__i__v__e__r__s__a__l __s__t__u__d__i__o , di dalam banyak sekali permainan menarik seperti untuk remaja maupun anak-anak , tempatnya agak panas karena open space , makanan di sini agak mahal jdnya di sarankan untuk makan dulu dan membawa minuman botol untuk bisa di refil ."
I want to replace the character before the underscore to an uppercase such that the output will be
ini adalah salah satu theme park yang terkenal yaitu UNIVERSAL STUDIO , di dalam banyak sekali permainan menarik seperti untuk remaja maupun anak-anak , tempatnya agak panas karena open space , makanan di sini agak mahal jdnya di sarankan untuk makan dulu dan membawa minuman botol untuk bisa di refil .
I would like to use list comprehension if possible.
print(''.join('_' + char.lower() if char.isupper() else char for char in inputstring).lstrip('_'))
UPDATE
Using Tim's answer works well on a single string but when I tried to put into a function and apply to all rows of a particular column in a dataframe, it does not seem to work. May I know what am I doing wrong here?
def uppercase(text):
text = re.sub(r'__(\w)', lambda m: m.group(1).upper(), text)
return text
df['review'] = df['review'].apply(lambda x: uppercase(x))
Here is a snapshot of the output I got after transferring the results to excel:
We can try using re.sub with a callback function, in which we capture __ followed by a single letter which is then uppercased.
inputstring = "ini adalah salah satu theme park yang terkenal yaitu __u__n__i__v__e__r__s__a__l __s__t__u__d__i__o , di dalam banyak sekali permainan menarik seperti untuk remaja maupun anak-anak , tempatnya agak panas karena open space , makanan di sini agak mahal jdnya di sarankan untuk makan dulu dan membawa minuman botol untuk bisa di refil ."
output = re.sub(r'__(\w)', lambda m: m.group(1).upper(), inputstring)
print(output)
This prints:
ini adalah salah satu theme park yang terkenal yaitu UNIVERSAL STUDIO , di dalam banyak sekali permainan menarik seperti untuk remaja maupun anak-anak , tempatnya agak panas karena open space , makanan di sini agak mahal jdnya di sarankan untuk makan dulu dan membawa minuman botol untuk bisa di refil .
Edit:
To do this on a Pandas dataframe column, we can use the above logic with str.replace:
df["review"] = df["review"].str.replace(r'__(\w)', lambda m: m.group(1).upper(), regex=True)

Check if Python list elements are in a Pandas dataframe row and append to a new column

I have a dataframe like this:
Casa
Name
Solo Deportes
Paleta De Padel Adidas Metalbone CTRL
Solo Deportes
Zapatillas Running Under Armour Charged Stamin...
Solo Deportes
Rompeviento Con Capucha Reebok Woven Azu
and a List:
Maestro_Marcas=['Adidas', 'Reebebok','Under Armour']
How can I check each row of df['Name'], see if the row contains a value of the list, and in that case get the value of the list and put it in the new column?. The result should be something like this:
Casa
Name
Marca
Solo Deportes
Paleta De Padel Adidas Metalbone CTRL
Adidas
Solo Deportes
Zapatillas Running Under Armour Charged Stamin...
Under Armour
Solo Deportes
Rompeviento Con Capucha Reebok Woven Azu
Reebok
You can try findall
df['Marca'] = df['Name'].str.findall('|'.join(Maestro_Marcas))
Notice,it will return a list of finding, if two items found within one Name, it will return both.
To match the output you need
df['Marca'] = df['Name'].str.findall('|'.join(Maestro_Marcas)).str[0]
you can use apply with a function such that:
Maestro_Marcas=['Adidas', 'Reebebok','Under Armour']
def is_exist(name):
for i in Maestro_Marcas:
if i in name:
return i
df['Marca'] = df.apply(lambda x: is_exist(x['Name']), axis=1)
desired result:
Casa Name Marca
0 Solo Deportes Paleta De Padel Adidas Metalbone CTRL Adidas
1 Solo Deportes Zapatillas Running Under Armour Charged Stamin... Under Armour
2 Solo Deportes Rompeviento Con Capucha Reebok Woven Azu None
I'm quite sure you should improve the function at one point for Reebebok vs Reebok adjust as you see fit.

How to decode bit code to emoji python pandas

How to decode bit code to emoji from each text of a row in pandas, study case sentiment analysis
Text
Sentimen
\xf0\x9f\x8e\xb6 la la la...hm hmm \xf0\x9f\x8e\xa7 "Semua diam ,semua bisu"\n"Kita coba tanya sama rumput yg bergoyang" \xe2\x99\xab\xe2\x99\xab\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xaa\xe2\x99\xaa'
Positif
Cerita silat lae \xf0\x9f\x98\x80 semacam wejangan
Negatif
sewot..\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 dukung dia terus
Positif
kunyuk!!!!\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 kuy gaslah
Negatif
aku sudah mengalaminya \xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 tetiba muncul grub wa
Negatif
g\n\nlagi bosan huft \xf0\x9f\x98\xaa
Negatif
How I want it to look:
Text
Sentimen
🎶 la la la...hm hmm 🎧 "Semua diam ,semua bisu"\n"Kita coba tanya sama rumput yg bergoyang" ♫♫♫♪♪♪''
Positif
Cerita silat lae 😀 semacam wejangan
Negatif
sewot...😂😂😂 dukung dia terus
Positif
kunyuk!!!!😂😂😂 kuy gaslah
Negatif
aku sudah mengalaminya 😂😂😂😂 tetiba muncul grub wa
Negatif
lagi bosan huft 😪
Negatif
I've tried it but make contents comments from text fields all become NaN
enter image description here
I'm out of ideas. Any help would be appreciated
Apply the encoding parameter while converting source to a data frame.
Example with hard-coded text:
import io
import pandas as pd
data_string='''
Text Sentimen
\xf0\x9f\x8e\xb6 la la la...hm hmm \xf0\x9f\x8e\xa7 "Semua diam ,semua bisu" "Kita coba tanya sama rumput yg bergoyang" \xe2\x99\xab\xe2\x99\xab\xe2\x99\xab\xe2\x99\xaa\xe2\x99\xaa\xe2\x99\xaa' Positif
Cerita silat lae \xf0\x9f\x98\x80 semacam wejangan Negatif
sewot..\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 dukung dia terus Positif
kunyuk!!!!\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 kuy gaslah Negatif
aku sudah mengalaminya \xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82\xf0\x9f\x98\x82 tetiba muncul grub wa Negatif
g lagi bosan huft \xf0\x9f\x98\xaa Negatif
'''.encode('latin1').decode('utf-8')
df = pd.read_csv( io.StringIO(data_string), sep="\t", encoding='utf-8')
print(df)
Output: .\SO\67060643.py
Text Sentimen
0 🎶 la la la...hm hmm 🎧 "Semua diam ,semua bisu"... Positif
1 Cerita silat lae 😀 semacam wejangan Negatif
2 sewot..😂😂😂 dukung dia terus Positif
3 kunyuk!!!!😂😂😂 kuy gaslah Negatif
4 aku sudah mengalaminya 😂😂😂😂 tetiba muncul grub wa Negatif
5 g lagi bosan huft 😪 Negatif

decoding to ut8 not working python

I am trying to scrape some data from a website in german. The code is as follows:
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import urllib2, requests
import time, sys
from selenium import webdriver
import os, sys
reload(sys)
sys.setdefaultencoding('utf-8')
chromedriver = "./chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
URL = 'http://de.vroniplag.wikia.com/'
def gethtml(link):
req = urllib2.Request(link, headers={'User-Agent': "Magic Browser"})
con = urllib2.urlopen(req)
html = con.read()
return html
Soup = lambda x: BeautifulSoup(x, 'html.parser')
def getplagtags(url):
soup = Soup(gethtml(url))
frgtab = soup.find('table', attrs={'class': 'ueberpruefte-fragmentseiten'})
frgs = [e['href'] for e in frgtab.findAll('a') if e['href'] and 'Seite nicht vorhanden' not in e['title']]
lst=[]
driver = webdriver.Chrome(chromedriver)
print frgs
for frg in frgs[0:1]:
url=URL+frg[1:]
print url
driver.get(url)
for tag in driver.find_elements_by_css_selector('[class^=fragmark]'):
lst.append([tag.get_attribute('class'),tag.text.encode('utf-8')])
driver.quit()
print lst
getplagtags('http://de.vroniplag.wikia.com/wiki/Aaf')
The result is as follows:
[[u'fragmark1', 'Verursacher von Infektionen in Krankenh\xc3\xa4usern und'], [u'fragmark2', 'auch in der Bev\xc3\xb6lkerung.'], [u'fragmark3', 'zwei Jahre nach der'], [u'fragmark4', 'des semisynthetischen Penicillin Methicillin,'], [u'fragmark5', 'zur Behandlung von Penicillin-resistentem S. aureus'], [u'fragmark6', 'in einem Krankenhaus in Boston'], [u'fragmark7', 'im Jahr 2006 circa 19.000 Menschen an MRSA-Infektionen.'], [u'fragmark8', 'die Zahl der station\xc3\xa4r behandelten MRSA-Infektionen'], [u'fragmark9', 'zwischen 700 und 1.500 Personen an einer'], [u'fragmark1', 'Die Zahl der Infizierten'], [u'fragmark2', 'Mortalit\xc3\xa4t der Patienten durch schwerwiegende Erkrankungen wie'], [u'fragmark3', 'oder Staphylococcal Scaled Skin Syndrome.'], [u'fragmark4', 'Kosten f\xc3\xbcr das Gesundheitssystem.'], [u'fragmark5', 'in der gegenw\xc3\xa4rtigen Forschung'], [u'fragmark6', 'sind.'], [u'fragmark6', '1.1. Methicillin-resistenter'], [u'fragmark7', 'durch Resistenzen gegen\xc3\xbcber allen Betalaktamantibiotika'], [u'fragmark8', 'als minimale Oxacillin-Hemmkonzentration von \xe2\x89\xa5 4 \xce\xbcg/mL.'], [u'fragmark9', 'einem mobilen genetischen Element.'], [u'fragmark1', 'Durch den Repressor MecI und den Tranducer MecRi'], [u'fragmark2', 'bekannt. Das mecA-Gen kodiert f\xc3\xbcr ein'], [u'fragmark7', 'Jevons MP, Coe AW, Parker MT. Methicillin resistance in staphylococci. Lancet 1963; 1:904-907'], [u'fragmark3', 'Barber M. Methicillin resistant staphylococci. J Clin Path'], [u'fragmark4', 'Barrett FF, McGehee RF Jr, Finland M. Methicillin-resistant Staphylococcus aureus at Boston City Hospital. Bacteriologic and epidemiologic observations. N Engl J Med 1968; 279;441-448'], [u'fragmark1', 'Klevens et al.: Invasive Methicillin-Resistant Staphylococcus aureus Infections in the United States. JAMA 298/15/2007. S. 1763'], [u'fragmark8', 'Klein E, Smith DL, Laxmiranayan R. Hospitalizations and deaths caused by Methicillin-resistant Staphylococcus aureus, United States, 1999'], [u'fragmark9', 'Infect Dis 2007; 13(12):1840-1846'], [u'fragmark2', 'Noskin GA, Rubin RJ,'], [u'fragmark3', 'et al. The burden of Staphylococcus'], [u'fragmark4', 'on hospitals in the United States: an analysis of the 2000 and 2001 Nationwide'], [u'fragmark5', 'Sample Database. Arch Intern Med 2005; 165:1756-1761'], [u'fragmark5', 'Deurenberg RH, Stobberingh EE. The evolution of Staphylococcus aureus. Infect'], [u'fragmark6', 'Evol. 2008 Jul 29.'], [u'fragmark1', 'Verursacher von Infektionen in Krankenh\xc3\xa4usern und'], [u'fragmark2', 'auch in der Bev\xc3\xb6lkerung.'], [u'fragmark3', 'zwei Jahre nach der'], [u'fragmark4', 'des semisynthetischen Penicillin Methicillin'], [u'fragmark5', 'zur Behandlung von Penicillin-resistentem S. aureus'], [u'fragmark6', 'in einem Krankenhaus in Boston'], [u'fragmark7', 'im Jahr 2006 circa 19.000 Menschen an MRSA-Infektionen'], [u'fragmark8', 'die Zahl der station\xc3\xa4r behandelten MRSA-Infektionen'], [u'fragmark9', 'zwischen 700 und 1.500 Personen an einer'], [u'fragmark1', 'die Zahl der Infizierten'], [u'fragmark2', 'Mortalit\xc3\xa4t der Patienten durch schwerwiegende Erkrankungen wie'], [u'fragmark3', 'oder Staphylococcal Scaled Skin Syndrome'], [u'fragmark4', 'Kosten f\xc3\xbcr das Gesundheitssystem,'], [u'fragmark5', 'in der gegenw\xc3\xa4rtigen Forschung'], [u'fragmark6', 'sind.'], [u'fragmark6', '1.1 Methicillin-resistenter'], [u'fragmark7', 'durch Resistenzen gegen\xc3\xbcber allen Betalaktamantibiotika'], [u'fragmark8', 'als minimale Oxacillin-Hemmkonzentration von \xe2\x89\xa5 4 \xce\xbcg/mL.'], [u'fragmark9', 'einem mobilen genetischen Element,'], [u'fragmark1', 'durch den Repressor MecI und den Tranducer MecRi'], [u'fragmark2', 'bekannt. Das mecA-Gen kodiert f\xc3\xbcr ein'], [u'fragmark3', 'Barber M. Methicillin resistant staphylococci. J Clin Path'], [u'fragmark4', 'Barrett FF, McGehee RF Jr, Finland M. Methicillin-resistant Staphylococcus aureus at Boston City Hospital. Bacteriologic and epidemiologic observations. N Engl J Med 1968; 279;441-448'], [u'fragmark5', 'Deurenberg RH, Stobberingh EE. The evolution of Staphylococcus aureus. Infect'], [u'fragmark6', 'Evol. 2008 Jul 29'], [u'fragmark7', 'Jevons MP, Coe AW, Parker MT. Methicillin resistance in staphylococci. Lancet 1963; 1:904-907'], [u'fragmark8', 'Klein E, Smith DL, Laxmiranayan R. Hospitalizations and deaths caused by Methicillin-resistant Staphylococcus aureus, United States, 1999'], [u'fragmark9', 'Infect Dis 2007; 13(12):1840-1846'], [u'fragmark1', 'Klevens et al.: Invasive Methicillin-Resistant Staphylococcus aureus Infections in the United States. JAMA 298/15/2007. S. 1763'], [u'fragmark2', 'Noskin GA, Rubin RJ,'], [u'fragmark3', 'et al. The burden of Staphylococcus'], [u'fragmark4', 'on hospitals in the United States: an analysis of the 2000 and 2001 Nationwide'], [u'fragmark5', 'Sample Database. Arch Intern Med 2005; 165:1756- 1761']]
My question is why is the text in the result (the second element in each list) is not in unicode, despite the fact that I am using the encode function.
UPDATE:
Removed the setdefaultencoding and the encode function. Now I get the following result
[[u'fragmark1', u'Verursacher von Infektionen in Krankenh\xe4usern und'], [u'fragmark2', u'auch in der Bev\xf6lkerung.'], [u'fragmark3', u'zwei Jahre nach der'], [u'fragmark4', u'des semisynthetischen Penicillin Methicillin,'], [u'fragmark5', u'zur Behandlung von Penicillin-resistentem S. aureus'], [u'fragmark6', u'in einem Krankenhaus in Boston'], [u'fragmark7', u'im Jahr 2006 circa 19.000 Menschen an MRSA-Infektionen.'], [u'fragmark8', u'die Zahl der station\xe4r behandelten MRSA-Infektionen'], [u'fragmark9', u'zwischen 700 und 1.500 Personen an einer'], [u'fragmark1', u'Die Zahl der Infizierten'], [u'fragmark2', u'Mortalit\xe4t der Patienten durch schwerwiegende Erkrankungen wie'], [u'fragmark3', u'oder Staphylococcal Scaled Skin Syndrome.'], [u'fragmark4', u'Kosten f\xfcr das Gesundheitssystem.'], [u'fragmark5', u'in der gegenw\xe4rtigen Forschung'], [u'fragmark6', u'sind.'], [u'fragmark6', u'1.1. Methicillin-resistenter'], [u'fragmark7', u'durch Resistenzen gegen\xfcber allen Betalaktamantibiotika'], [u'fragmark8', u'als minimale Oxacillin-Hemmkonzentration von \u2265 4 \u03bcg/mL.'], [u'fragmark9', u'einem mobilen genetischen Element.'], [u'fragmark1', u'Durch den Repressor MecI und den Tranducer MecRi'], [u'fragmark2', u'bekannt. Das mecA-Gen kodiert f\xfcr ein'], [u'fragmark7', u'Jevons MP, Coe AW, Parker MT. Methicillin resistance in staphylococci. Lancet 1963; 1:904-907'], [u'fragmark3', u'Barber M. Methicillin resistant staphylococci. J Clin Path'], [u'fragmark4', u'Barrett FF, McGehee RF Jr, Finland M. Methicillin-resistant Staphylococcus aureus at Boston City Hospital. Bacteriologic and epidemiologic observations. N Engl J Med 1968; 279;441-448'], [u'fragmark1', u'Klevens et al.: Invasive Methicillin-Resistant Staphylococcus aureus Infections in the United States. JAMA 298/15/2007. S. 1763'], [u'fragmark8', u'Klein E, Smith DL, Laxmiranayan R. Hospitalizations and deaths caused by Methicillin-resistant Staphylococcus aureus, United States, 1999'], [u'fragmark9', u'Infect Dis 2007; 13(12):1840-1846'], [u'fragmark2', u'Noskin GA, Rubin RJ,'], [u'fragmark3', u'et al. The burden of Staphylococcus'], [u'fragmark4', u'on hospitals in the United States: an analysis of the 2000 and 2001 Nationwide'], [u'fragmark5', u'Sample Database. Arch Intern Med 2005; 165:1756-1761'], [u'fragmark5', u'Deurenberg RH, Stobberingh EE. The evolution of Staphylococcus aureus. Infect'], [u'fragmark6', u'Evol. 2008 Jul 29.'], [u'fragmark1', u'Verursacher von Infektionen in Krankenh\xe4usern und'], [u'fragmark2', u'auch in der Bev\xf6lkerung.'], [u'fragmark3', u'zwei Jahre nach der'], [u'fragmark4', u'des semisynthetischen Penicillin Methicillin'], [u'fragmark5', u'zur Behandlung von Penicillin-resistentem S. aureus'], [u'fragmark6', u'in einem Krankenhaus in Boston'], [u'fragmark7', u'im Jahr 2006 circa 19.000 Menschen an MRSA-Infektionen'], [u'fragmark8', u'die Zahl der station\xe4r behandelten MRSA-Infektionen'], [u'fragmark9', u'zwischen 700 und 1.500 Personen an einer'], [u'fragmark1', u'die Zahl der Infizierten'], [u'fragmark2', u'Mortalit\xe4t der Patienten durch schwerwiegende Erkrankungen wie'], [u'fragmark3', u'oder Staphylococcal Scaled Skin Syndrome'], [u'fragmark4', u'Kosten f\xfcr das Gesundheitssystem,'], [u'fragmark5', u'in der gegenw\xe4rtigen Forschung'], [u'fragmark6', u'sind.'], [u'fragmark6', u'1.1 Methicillin-resistenter'], [u'fragmark7', u'durch Resistenzen gegen\xfcber allen Betalaktamantibiotika'], [u'fragmark8', u'als minimale Oxacillin-Hemmkonzentration von \u2265 4 \u03bcg/mL.'], [u'fragmark9', u'einem mobilen genetischen Element,'], [u'fragmark1', u'durch den Repressor MecI und den Tranducer MecRi'], [u'fragmark2', u'bekannt. Das mecA-Gen kodiert f\xfcr ein'], [u'fragmark3', u'Barber M. Methicillin resistant staphylococci. J Clin Path'], [u'fragmark4', u'Barrett FF, McGehee RF Jr, Finland M. Methicillin-resistant Staphylococcus aureus at Boston City Hospital. Bacteriologic and epidemiologic observations. N Engl J Med 1968; 279;441-448'], [u'fragmark5', u'Deurenberg RH, Stobberingh EE. The evolution of Staphylococcus aureus. Infect'], [u'fragmark6', u'Evol. 2008 Jul 29'], [u'fragmark7', u'Jevons MP, Coe AW, Parker MT. Methicillin resistance in staphylococci. Lancet 1963; 1:904-907'], [u'fragmark8', u'Klein E, Smith DL, Laxmiranayan R. Hospitalizations and deaths caused by Methicillin-resistant Staphylococcus aureus, United States, 1999'], [u'fragmark9', u'Infect Dis 2007; 13(12):1840-1846'], [u'fragmark1', u'Klevens et al.: Invasive Methicillin-Resistant Staphylococcus aureus Infections in the United States. JAMA 298/15/2007. S. 1763'], [u'fragmark2', u'Noskin GA, Rubin RJ,'], [u'fragmark3', u'et al. The burden of Staphylococcus'], [u'fragmark4', u'on hospitals in the United States: an analysis of the 2000 and 2001 Nationwide'], [u'fragmark5', u'Sample Database. Arch Intern Med 2005; 165:1756- 1761']]
You decode from str to unicode and encode from unicode to str. tag.text.encode('utf-8') obviously gives you exactly what you asked for, just call tag.text as you already have a unicode string:
[tag.get_attribute('class'),tag.text]
Also avoid reload(sys) and sys.setdefaultencoding('utf-8'), why-should-we-not-use-sys-setdefaultencodingutf-8-in-a-py-script

Regular Expressions: pull the data between "FOO" and "BAR"

I have this string right here:
*TACK F\u00d6R DIN BOKNING MED RYANAIR*****\r\n------------------------------\r\n\r\nV\u00e4nligen svara inte p\u00e5 detta e-postmeddelande.****\r\n------------------------------\r\n\r\nDITT BOKNINGSNUMMER \u00c4R:* A1A1A1*****\r\n\r\nF\u00d6R ATT F\u00c5 RESA M\u00c5STE DU CHECKA IN VIA INTERNET OCH P\u00c5 FLYGPLATSEN VISA UPP\r\nDITT INTERNETBOARDINGKORT OCH GILTIG ACCEPTERAD RESEHANDLING. PASSAGERARE\r\nSOM INTE VISAR UPP ETT BOARDINGKORT P\u00c5 FLYGPLATSEN KOMMER ATT BLI\r\nDEBITERADE EN STRAFFAVGIFT F\u00d6R NY-UTSKRIFT P\u00c5 EURO40/GBP40.(varje\r\nboardingkort m\u00e5ste vara utskrivet och presenteras p\u00e5 individuella A4-ark).**\r\n**\r\n\r\nDu kan checka in via Internet fr\u00e5n 15 dagar fram till 4 timmar innan\r\nflygets schemalagda avg\u00e5ng.****\r\n\r\nRESEPLAN/KVITTO \u2013 alla tider \u00e4r lokala.****\r\n\r\nUTRESA****\r\n\r\nFr\u00e5n Milano (Bergamo) (BGY) till Stockholm Skavsta (NYO)\r\nSat, 14Aug10 Flyg FR1944 Avg\u00e5ng BGY kl 21:00 och ankomst NYO kl 23:30****\r\n\r\nPASSAGERARE****\r\n\r\n
And, I need to pull the data between "UTRESA" and "PASSAGERARE". So I tried this:
re.search(r'UTRESA (.+)PASSAGERARE',x)
And for some reason its not pulling the data! Could you guys explain to my why I'm not pulling the data, and a solution for it?
You need to use the DOTALL flag when matching newlines:
re.search(r'UTRESA(.+)PASSAGERARE', x, re.DOTALL)
and there's no space after UTRESA.
Demo:
>>> re.search(r'UTRESA(.+)PASSAGERARE', x, re.DOTALL).groups()
('****\r\n\r\nFr\\u00e5n Milano (Bergamo) (BGY) till Stockholm Skavsta (NYO)\r\nSat, 14Aug10 Flyg FR1944 Avg\\u00e5ng BGY kl 21:00 och ankomst NYO kl 23:30****\r\n\r\n',)

Categories

Resources