ErwinHaasnoot / qrteparser-webservice

QRTEParser webservice written in Python for Django
3 stars 4 forks source link

Parser in Python 2.7 vs 3 #4

Open becky-gilbert opened 8 years ago

becky-gilbert commented 8 years ago

Hi Erwin,

I just tried using the parser with Python 2.7 and Windows 7 64-bit, and I got the following error:

File "C:\Python27\qrteparser-webservice-master\parser.py", line 27, in main(*sys.argv[1:]) File "C:\Python27\qrteparser-webservice-master\parser.py", line 22, in main QRTEParser.parse(file, outfile=file.split('.')[0]+'_out.csv',exit_q_unique = False) File "C:\Python27\qrteparser-webservice-master\qrte_parser_python\qrteparser.py", line 20, in parse parser._parse() File "C:\Python27\qrteparser-webservice-master\qrte_parser_python\qrteparser.py", line 32, in _parse node.write_data(self.file, self.outfile) File "C:\Python27\qrteparser-webservice-master\qrte_parser_python\qrtemarkupnode.py", line > 94, in write_data csvwriter.open(outfile) File "C:\Python27\qrteparser-webservice-master\qrte_parserpython\qrtecsv.py", line 63, in open cls.filehandler = gzip.open(file+'.gz','wt') File "C:\Python27\lib\gzip.py", line 34, in open return GzipFile(filename, mode, compresslevel) File "C:\Python27\lib\gzip.py", line 94, in init fileobj = self.myfileobj = builtin.open(filename, mode or 'rb') ValueError: Invalid mode ('wtb')

The parser produced an output file containing some of the embedded data, but that's it. I googled the error and found this, which suggests that it's a Python version issue. This seems strange since I'm sure I've used the parser with 2.7 before without any issues, and you mention using 2.7 in the instructions here.

I then tried the parser in Python 3 and didn't get an error. The output file looks great except that there are additional blank rows between each row of data.

Any idea what's going on here? Am I doing something wrong? I can email you the files if you'd like them.

Thanks very much! Becky

becky-gilbert commented 8 years ago

Hi again,

Sorry, I just realised that the Python 3 output is fine when I read it into R. So to get rid of the extra blank lines in Excel, I just wrote the file back out as csv from R.

Becky