|
From: Marc T. <mar...@gm...> - 2009-03-01 20:12:20
|
I'm using ConfigObj to parse Medicare's list of error/comment codes (when a physician receives an electronic explanation of benefits, it's full of these codes telling him/her exactly why Medicare isn't paying squat.) The file is called "Codes.ini", and generally follows INI conventions, except that: - the first line is a release date - no "=", no nothing. I got around that by opening the file first, doing a readlines(), and pop()ing the date off for use elsewhere. - at about 75%, the following appears: > [188] > Message=This product/procedure is only covered when used according to FDA > recommendations. > EffDate=6/30/2005 > DeactDate= > Modified= > Note= > [189] > Message='Not otherwise classified' or 'unlisted' procedure code (CPT/HCPCS) > was billed when there is a specific procedure code for this > procedure/service > EffDate=6/30/2005 > DeactDate= > Modified= > Note= (I include number 188 just to show what these entries look like - the trouble begins with the Message for number 189.) Here's what I get: > Traceback (most recent call last): > File "E:\fsrPy\fsrStuff\mcrCodes.pyw", line 19, in <module> > codeFile = mcrCodes() > File "E:\fsrPy\fsrStuff\mcrCodes.pyw", line 17, in __init__ > self.codes = ConfigObj(tmpCodes, raise_errors=True) > File "C:\Python25\lib\site-packages\configobj.py", line 1272, in __init__ > self._load(infile, configspec) > File "C:\Python25\lib\site-packages\configobj.py", line 1341, in _load > self._parse(infile) > File "C:\Python25\lib\site-packages\configobj.py", line 1687, in _parse > ParseError, infile, cur_index) > File "C:\Python25\lib\site-packages\configobj.py", line 1748, in > _handle_error > raise error > configobj.ParseError: Parse error in value at line 5888. > There aren't any "real" quotes in this file - is there any way to tell ConfigObj to ignore any single-quote characters it finds? If not, any clever ideas for a workaround? I did think of replacing "'" with "-" or something, but there are plenty of contractions in this file, and "doesn-t" doesn't look very pretty. On the other hand, searching for all matched pairs of quotes that appear in the same data item would require me to... well, to re-invent much of the guts of ConfigObj itself, no? If you're interested, the code file is available here: http://www.cms.hhs.gov/AccesstoDataApplication/Downloads/MedicareRemitEasyPrint.zip (it's inside the zip file). Thanks! -- www.fsrtechnologies.com |