Giter VIP home page Giter VIP logo

Comments (6)

jseutter avatar jseutter commented on July 22, 2024

Hi Marwan, that is a new bug, probably as a result of recent changes to
support Python 3. I see you're running Python 3, that's great!

If you want to try a quick fix just to get your file parsed, try changing
that line to something like:

head_data = head_data[:head_data.find('<')]

... my guess is that we were too zealous with using the bytes type
everywhere. At any rate, let me know if that helps and I'll try to code up
a test and a fix on the weekend.

Jerry

On Thu, Nov 7, 2013 at 6:01 AM, Marwan Rabbâa [email protected]:

Hi,

I use OFX format to deal with financial data. I've found this librariry
to automate parsing (so this my first use of this package).

I try

import os>>> from ofxparse import OfxParser>>> file = open(os.path.expanduser('~/20131107.ofx'))>>> ofx = OfxParser.parse(file)

but I have this traceback

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 330, in parse
ofx_file = OfxPreprocessedFile(file_handle)
File "/usr/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 141, in init
super(OfxPreprocessedFile,self).init(fh)
File "/usr/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 71, in init
self.read_headers()
File "/usr/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 77, in read_headers
head_data = head_data[:head_data.find(six.b('<'))]TypeError: Can't convert 'bytes' object to str implicitl

Is anybody ever had this bug ?

Regards,


Reply to this email directly or view it on GitHubhttps://github.com//issues/63
.

from ofxparse.

waghanza avatar waghanza commented on July 22, 2024

Hi,

Thanks for update.

As far as I should use an ofx parser compliant with the lastest stable python version, I will use this package.

I'll make a pull request to fix this (probably in the next 6 hours).

Regards,

from ofxparse.

rkhwaja avatar rkhwaja commented on July 22, 2024

I tried this proposed fix and I get a different error:

Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 330, in parse
ofx_file = OfxPreprocessedFile(file_handle)
File "/usr/local/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 141, in init
super(OfxPreprocessedFile,self).init(fh)
File "/usr/local/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 71, in init
self.read_headers()
File "/usr/local/lib/python3.3/site-packages/ofxparse/ofxparse.py", line 79, in read_headers
for line in re.split(six.b('\r?\n?'), head_data):
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/re.py", line 191, in split
return _compile(pattern, flags).split(string, maxsplit)
TypeError: can't use a bytes pattern on a string-like object

from ofxparse.

mattijs avatar mattijs commented on July 22, 2024

Hi, I'm just trying to bump this issue.

The little example from the README works great in python2 but I'm still seeing this error running python3 (3.5.1). The proposed solution (changing the line(s) to simple strings) works but is not really a fix.

The problem is six.b returning a latin encoded byte string instead of a regular string for python3 (there is a PY3 check) that causes the error.

from ofxparse.

mattijs avatar mattijs commented on July 22, 2024

Just a side note, opening the input file in binary mode (rb) fixes the problem. This should probably be mentioned as a requirement in the README.

from ofxparse.

jseutter avatar jseutter commented on July 22, 2024

I updated README to open the file in binary mode. Thank you for reporting this.

from ofxparse.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.