Closed ewancarr closed 8 years ago
Where there are comments after line continuation marks (///), the line continuation regex in text_2_stata.py isn't triggered, so the line continuation marks are stripped altogether.
///
text_2_stata.py
For example:
label define countryname /// 1 "Belgium" /// BE 2 "Bulgaria" /// BG 3 "Switzerland" /// CH 4 "Cyprus" // CY
Results in:
. label define countryname 1 "Belgium" . 2 "Bulgaria" unrecognized command: 2 invalid command name r(199); . 3 "Switzerland" unrecognized command: 3 invalid command name r(199); . 4 "Cyprus" unrecognized command: 4 invalid command name r(199);
I've found that extending the line continuation regex (line 18), to additionally match anything after ///, fixes this.
From:
clean = re.sub("/{3,}\\n", " ", clean)
To:
clean = re.sub("/{3,}.*\\n", " ", clean)
But I haven't tested this extensively.
Notably, even a single space after the line continuation marks will trigger this bug.
Problem
Where there are comments after line continuation marks (
///
), the line continuation regex intext_2_stata.py
isn't triggered, so the line continuation marks are stripped altogether.For example:
Results in:
Fix
I've found that extending the line continuation regex (line 18), to additionally match anything after
///
, fixes this.From:
To:
But I haven't tested this extensively.