mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-22 03:30:04 -05:00
README: add example for parsing local file
This commit is contained in:
parent
0d93a42626
commit
9136c9bab2
23
README.md
23
README.md
@ -13,7 +13,7 @@ library.
|
|||||||
|
|
||||||
The main purpose of this project is to provide a library to make it easier to
|
The main purpose of this project is to provide a library to make it easier to
|
||||||
query financial information with OFX from the comfort of Golang, without having
|
query financial information with OFX from the comfort of Golang, without having
|
||||||
to marshal/unmarshal to SGML or XML. The library does *not* intend to abstract
|
to marshal/unmarshal to SGML or XML. The library does _not_ intend to abstract
|
||||||
away all of the details of the OFX specification, which would be difficult to do
|
away all of the details of the OFX specification, which would be difficult to do
|
||||||
well. Instead, it exposes the OFX SGML/XML hierarchy as structs which mostly
|
well. Instead, it exposes the OFX SGML/XML hierarchy as structs which mostly
|
||||||
resemble it. Its primary goal is to enable the creation of other personal
|
resemble it. Its primary goal is to enable the creation of other personal
|
||||||
@ -94,6 +94,27 @@ if stmt, ok := response.Bank[0].(*ofxgo.StatementResponse); ok {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Similarly, if you have an OFX file available locally, you can parse it directly:
|
||||||
|
|
||||||
|
```go
|
||||||
|
func main() {
|
||||||
|
f, err := os.Open("./transactions.qfx")
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("can't open file: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
resp, err := ofxgo.ParseResponse(f)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("can't parse response: %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// do something with resp (*ofxgo.Response)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
OFXGo requires go >= 1.12
|
OFXGo requires go >= 1.12
|
||||||
|
Loading…
Reference in New Issue
Block a user