I do not have openpyxl module in my system, so I tried your regular expression with a simple text file with some dummy data that matches your regex pattern.
Note a couple of things:
1) Characters like ";" and ":" do not have special meaning in a regex, so they need not be escaped by backslash "\" character.
2) The hyphen "-" has special meaning only inside brackets. Otherwise, it need not be escaped.
3) You can reduce the regular expression, but it becomes unreadable very quickly. That's true for any regular expression. So you have to find a balance between readability and succinctness.
If you try hard enough, you can reduce that regex to a single string.
But the maintainer of your script may not be very happy about it.
Last edited by durden_tyler; 06-01-2017 at 04:43 PM..
This User Gave Thanks to durden_tyler For This Post:
Hi,
I am trying to find a way to read an excel work book with multiple worksheets.
And write each worksheet into a new excel file using perl. My environment is Unix.
For example: I have an excel workbook TEST.xls and it has Sheet1, Sheet2, Sheet3 worksheets. I would like to create... (2 Replies)
I have the below string and regex. However I cant understand why it works the way it does. IP has been changed for safety ;)
String = NowSMS Error Report. Error initializing SMSC Interface 'SMPP - 10.15.8.10:17600'. Interface is not available.
Regex = (.+\.)\s(.+)
I get two... (1 Reply)
Hi list,
This is probably something really simple, but I am not particularly familiar with Python so I thought I would ask as I know that python has an excel module.
I have an excel document with multiple tabs of data and graphs.
One of the tabs is just data which I require to have dumped to... (8 Replies)
I starting teaching myself python and am stuck on trying to understand why I am not getting the output that I want. Long story short, I am using PDB for debugging and here my function in which I am having my issue:
import re
...
...
...
def find_all_flvs(url):
soup =... (1 Reply)
All,
I have an excel sheet Excel1.xls that has some entries.
I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls
These may be in different workbooks. They are totally independent made by 2 different users.
I have placed them in a... (1 Reply)
As a newbie to Python, I am trying to write a script in which is will add all the log files (*.log) from within a directory to a list, open the files and search for an ip using a regex and single it out (appending the ip's to the list). So far, I have:
import re, os
def list_files()
content = ... (4 Replies)
Well, I'm a python noob and my last post here I was introduced to Regex. I thought this would be easy since I knew Regex with Bash. However, I've been banging my head a while to extract an ip address from ifconfig with this:
#!/usr/bin/python
import re
import subprocess
from subprocess... (5 Replies)
Here is a snippet of my code:
blahblahblah...
blah
for link in goodies.soup.find_all('a'):
blah.append(link.get('href'))
blah=list(set(blah))
which gives my list of urls. So now I use a regex to search for the relevant urls which I want in a list:
for r... (0 Replies)
Hi,
Anyone can help I am just converting the excel file to csv using python, I can get the conversion output but the date not display exactly.
test.xlsx date format
167 1588 risks/SCS JP CAMPANA & CIE.pdf SCS JP CAMPANA & CIE 2 1 1 0 2015-03-16 16:56:25
167 1146 risks/AirBNB... (1 Reply)
Hello,
I have an excel sheet with 11 tabs. I need to take data from the first tab and write the output to the second tab. The first tab looks like this, starting from Row 3
The filters that needs to be created are
1) keep anything greater than 'POS' 5 and less than 160 AND
2)... (2 Replies)