I'm sure you see this a lot but just wanted to warn you that I'm still very new to coding in general and have a lot to learn. I've been attempting teaching myself by working on a personal project and youtube whenever I have the time.
Long version: I always get an error when I use the split function, but I still get a value. Essentially what my function is supposed to do is take an angle or bearing that is in degrees°minutes'seconds" or for example "N 38°43'23\" E" to a decimal number. I took advantage of bearings being less than 90 degrees to use indexing to find the numbers in the string to convert the angle. However, if the angle wasn't a bearing, I couldn't think of a way to figure out how many tens places the degrees to pull the number out so I tried splitting it at the degree symbol. When it does this, though, it returns an error saying split() requires a non-empty pattern match. What does this mean? The code still works, but always returns this error with it.
Short version: Here's my code:
def decimal(x): # converts degrees-minutes-seconds to decimal
dms = list(x)
if dms == 'N' or dms == 'S':
degrees = ((int(dms) * 10) + int(dms))
minutes = ((int(dms[-8]) * 10) + int(dms[-7])) / 60
seconds = ((int(dms[-5]) * 10) + int(dms[-4])) / 3600
placeholder = re.split(r'\u00b0*', x)
degrees = int(placeholder)
minutes = ((int(dms[-6]) * 10) + int(dms[-5])) / 60
seconds = ((int(dms[-3]) * 10) + int(dms[-2])) / 3600
return degrees + minutes + seconds
FutureWarning: split() requires a non-empty pattern match.
return _compile(pattern, flags).split(string, maxsplit)
What you have is not an error, it's a warning.
For one, I think you should not use a raw string, you need
'\u00b0', the character. And
'c*' will match 0 or more of
c, so it matches the empty string. I believe this is what the warning is about. I suggest that you use
Or even better, just