Comments (6)
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 implicitlIs anybody ever had this bug ?
Regards,
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/63
.
from ofxparse.
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.
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.
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.
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.
I updated README to open the file in binary mode. Thank you for reporting this.
from ofxparse.
Related Issues (20)
- Python3 "TypeError: must be str, not bytes"
- 'str' object has no attribute 'strftime' in ofxprinter HOT 1
- Not able to read file with iso-8859-1 encoding
- Changing <FITID> is not persisting at all HOT 1
- Make dtuser available in transaction object.
- OfxParser.parse fails: unknown encoding: cpNONE
- Importing ABC directly from collections module was removed in Python 3.9 HOT 3
- transaction.security and position.security should be Security() object instead of str HOT 1
- Read an OFX String instead of a OFX file HOT 4
- Transaction that is not a DEBIT nor a CREDIT HOT 2
- Missing BANKACCTTO on statement transaction
- Close tags HOT 2
- Does this parse ofx 1.0 format?
- OfxPreprocessedFile() crashes on an empty close tag like this: <MEMO/>
- Module 'collections' has no attribute 'Iterable' HOT 1
- Cannot process UTF-8 files with characters outside the 256 range HOT 1
- XMLParsedAsHTMLWarning HOT 4
- Bug with encoding for ETrade
- Handling Missing Decimal Separators in BALAMT Field for Brazilian OFX Files
- Feature Request - Add Transaction Parsing for "DTAVAIL" Field in <STMTTRN>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxparse.