how to edit ofx file with sed editor? Replace Copy FITID into NAME
Chris Good
chris.good at ozemail.com.au
Wed Sep 14 20:53:58 EDT 2016
> Message: 12
> Date: Tue, 13 Sep 2016 22:19:37 -0700 (PDT)
> From: LinforPros <linforpros at gmail.com>
> To: gnucash-user at gnucash.org
> Subject: RE: how to edit ofx file with sed editor? Replace Copy FITID
> into NAME
> Message-ID: <1473830377114-4686564.post at n4.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
> Here is the snippet of the file my bank produces:
>
>
> And testing for the kind of line endings with "cat -e FILENAME" shows:
>
>
> Which seems like LF and the end, without CR.
>
> I would be happy to see the awk script that can copy text from the double
> "**" to the end of the line in the FITID and then paste it into the NAME
tag,
> replacing its current value.
>
> Thank you for taking the time to solve my problem.
>
> regards,
> Lin
Hi Lin,
For some reason your data lines were stripped from the GnuCash mail but I
got them from nabble.
Here is the script:
/^<STMTTRN>/ {
name=""
}
/^<FITID>/ {
idx=index($0, "**")
if (idx > 0) {
name=substr($0, idx+2)
}
}
/^<NAME>/ {
if (length(name) > 0) {
print "<NAME>" name
next
}
}
{ print }
I suggest saving the above lines in file ofx.awk, then execute it by
awk -f ofx.awk ofx.in > ofx.out
where ofx.in is the name of your input ofx file and ofx.out is the name of
the modified output file.
If there is no ** in the FITID, the NAME line is written out unchanged.
I have attached the script in file ofx.txt in case mail corrupts something.
Regards, Chris Good
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ofx.txt
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20160915/3229ceba/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4817 bytes
Desc: not available
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20160915/3229ceba/attachment.p7s>
More information about the gnucash-user
mailing list