Importing and Export

GnuCash Importer

GnuCash Files
The GnuCash importer handles direct reading of standard () files as produced by GnuCash versions 1.8 and 2.0. The following are not supported:
import of database (Postgres) data
import of 'multi-book' files
import into an existing file
import of small-business specific features (Employees, Invoices, etc.)
export to GnuCash files.
The import will probably only work correctly if presented with a valid file. It is recommended that the GnuCash Check & Repair All function (in the Actions menu) be run before attempting to import.
Files can be opened by specifying the filename on the command line (kmymoney <path to file>), or by means of the O File Open or File Import menu items.
The similarity between the two products means that much day-to-day data can be imported in a straightforward fashion. However, there are some areas where differences arise, and various options are provided to deal with these. The following sections will describe some of these differences; understanding them should lead to a smoother importation.

Similarities, Differences, and Terminology

Small Business Usage
It should be noted that is a personal finance manager, and as such, does not directly support any of the business features of GnuCash, such as tax tables, payroll, and tracking of lots. Any Accounts Payable or Receivable accounts found in a file will be imported as Liability or Asset accounts respectively.

Accounts

Account types
For both products, the highest level of structure in the file is the account. supports 5 main types of account: Asset, Liability, Income, Expense and Equity, each of which may have various subtypes, ⪚, Checking, Credit Card, . includes a 'standard' account for each of these five types, and all other accounts are held subordinate to one of these. enforces more consistency (or less flexibility, depending on your point of view) between account types than does GnuCash, and the importer will correct any inconsistencies it detects. This may result in a slightly different account structure, though this can, within reason, be amended after the import is complete.

Categories
uses the term Category to denote an account of an Income or Expense type. Unlike GnuCash, these are not considered as 'ledger' accounts, and entry of transactions folder into categories is not supported; allocations are made during transaction entry into other account types.

Structure and Placeholders
GnuCash supports the use of Placeholder accounts. In effect, these are just read-only accounts into which no transactions can be entered, but which function in an analogous fashion to folders in a folder structure, as a holder for other accounts. Though does not support this feature as such, it does provide a parent/child account relationship, so the importer simulates placeholders by creating empty accounts.

Account Type map
GnuCash type	type
BANK	Checking
CHECKING	Checking
SAVINGS	Savings
ASSET	Asset
CASH	Cash
CURRENCY	Cash
MONEYMRKT	MoneyMarket
STOCK	Stock
MUTUAL	Stock
EQUITY	Equity
LIABILITY	Liability
CREDIT	CreditCard
INCOME	Income
EXPENSE	Expense
RECEIVABLE	Asset
PAYABLE	Liability

Transactions and Splits

Balanced transactions
As with GnuCash, data is entered in the form of transactions, each generally consisting of 2 or more split entries. In fact, valid GnuCash transactions will always contain at least 2 splits, and to conform to GnuCash's double-entry bookkeeping standard, these must be in monetary balance (i.e., they must balance out to zero). encourages, but does not enforce, this standard, but any imported transaction which is not balanced will be marked in the ledger view as having a problem.

Payees
prefers that all transactions have a Payee (a generic term that encompasses both payees and payers), and unlike GnuCash, a list of these payees is maintained. Payee names are generated by the importer from the GnuCash transaction's Description field.

Transfers
uses the term Transfer to describe a transaction which does not involve a Category, but only transfers money between Asset and/or Liability accounts.

Reconcile
provides an account reconciliation function similar to that of GnuCash, and the corresponding transaction status will be imported.

Commodities
GnuCash uses the term Commodity to cover both currencies and non-currency assets. These are treated separately in .

Currencies
has built-in support for all foreign currency types. also requires that the user specify a base currency, this being the default currency for new accounts. The importer will attempt to determine the most likely base currency, though this choice may be rejected in favor of an alternative.
(NOTE: does not currently support accounts denominated in 'defunct' currencies (except those replaced by the Euro). At present, it will be necessary to remove any such accounts from your GnuCash file before importing. We hope to improve on this situation in a future release.)

Securities and Investments
Non-currency assets (normally stocks and bonds) are called Securities by , and represent the main difference between the two products, in that requires any account denominated in a security to be subordinate to an Investment Account. This is described in more detail in the chapter on Investments. Though users may have implemented such a relationship, GnuCash imposes no defined structure on it, so the importer is unable to detect it and perform an automatic conversion. Three options are therefore made available:
Create a separate Investment account for each security, with the same name as the security
Create a single Investment account which will act as 'parent' for all security accounts
Create several Investment accounts, and assign securities to them as directed by the user.
It depends entirely on user requirements which of these options is relevant in each situation, and in some cases, manual restructuring of accounts after importation may be necessary.

Prices and currency rates
Security prices and currency exchange rates as displayed in the GnuCash Price Editor will be imported. In addition, price and rate entries will be generated from all transactions involving securities and multiple currencies.

Online Quotes
For obtaining online price and currency rate quotations, GnuCash uses a package called Finance::Quote. Recent versions of contain support for this package for obtaining stock quotes, and this will be used by default when importing data. You may however select to convert to the native method used by which is covered in more detail in online quotes.
If you choose to do so, the following dialog will allow selection of a 'native' price source, or a user-defined source, for each account for which online quotes are required. However, the stock (ticker) symbol will be imported unchanged. Since this symbol will almost certainly be different in the two packages, it will need to be manually edited after completion of the import process. Future currency rate updates will not use Finance::Quote, and will always use the native retrieval method.

Scheduled Transactions
does not retain the separation made in GnuCash between template transactions and their frequency of occurrence. Transaction data will be duplicated if the same template is used in different schedules, but this is not likely to be of great significance.

Schedule types
classifies all schedules as one of three types, Bills, Deposits, or Transfers. Since GnuCash does not make such a distinction, the importer attempts to determine the classification from the accounts and direction of money movements. It may be that in some cases incorrect assumptions are made, and these will need manual correction.

Suspect Schedules
Some features of GnuCash scheduled transactions are not available in , so the importer tries in each case to reach a reasonable compromise in converting the data. These transactions will be flagged as suspect, and the user will be given the option of editing them directly during the import process. Examples of situations which may cause this are:
some frequency intervals supported in GnuCash are not currently available in
does not support the use of formulae and variables in amount fields
complex cases which have not yet been identified for import.
Despite best efforts, it is possible that, due to the many options involved, a scheduled transaction may cause a fatal error within . If this sort of problem seems to be occurring, the importer offers the option to drop all suspect schedules.

Reports
provides a comprehensive selection of configurable reports, described in more detail in Reports. These will not necessarily, however, match precisely those reports available in GnuCash.

Selecting Importer Options

Investment Handling
See "Securities and Investments" above.

Online Quotes
Turn this off if you wish to use the native method for future online price quotes.
See "Online Quotes" above.

Scheduled Transactions
See "Scheduled Transactions" above.

Decoding Options
If your native language is written in letters or symbols which are different from those used in the 'Latin' languages (i.e., generally Western European), these are represented in a special fashion ('encoded') in your GnuCash file. If these letters are not displayed correctly on your screen, then they must be decoded. Currently, it is often not possible to detect accurately which form of decoding must be used, so you may need to set this option and select an entry from the list. In general, the first item in the list will be that which is considered appropriate for your locale (i.e., the country and language which was selected as native when your operating system was installed), so this should be tried first. Since the import process does not overwrite your GnuCash file, you are free to experiment with any of these selections.

Transaction Notes option
Under some usage conditions, non-split GnuCash transactions may contain residual, often incorrect, memo data which is not normally visible to the user. When imported into however, due to display differences, this data can become visible. Often, these transactions will have a Notes field describing the real purpose of the transaction. If this option is selected, these notes, if present, will be used to override the extraneous memo data.

Debug Options
These need only be used in the event of import problems. If you have such problems, you should also report them to the developer list . Note that the traces produced by these options may contain data of a confidential nature, and the Anonymize option should be used if they are to be made publicly available.

Import Report
At the end of processing, the importer produces a report showing the number of different entities processed, and any errors or anomalies encountered. This report will be displayed on screen, and may be saved to a file for later review. A full report may contain the following sections:
Record counts
Inconsistencies in account types and actions taken
Details of suspect schedules

QIF Importer

QIF format considered harmful
Generally speaking, the QIF format should be avoided wherever possible. It is a poor choice for transporting financial data. Among other things, QIF suffers from these problems:
Lack of standardized format: Different versions of the same program will impart different meanings to the same element.
Lack of transaction identifier: Because there is no ID number associated with each transaction, matching duplicate transactions is haphazard at best.
Lack of expressiveness: The grammar is really simple, and cannot portray the depth of financial information found in today's financial environment.
This is generally why Intuit stopped supporting QIF input at all with Quicken 2005. If you have the option of getting data some other way, like OFX, always choose that option.

How to import a QIF file
To import a QIF file, first ensure you have a valid file open. Then select Import QIF from the File menu.
The resulting dialog prompts for the QIF filename allowing you to locate the file by clicking on the Browse button.
Also, differentiates between the import of a bank statement file and historic data exported from another application. The default is to import a bank statement file. In case you are importing data from your previous personal finance manager application select the appropriate option.
In general the default QIF profile should work with your QIF data. In some cases it might become necessary to use a modified QIF profile. See the next section for more details on that subject.
Click on Import to import the QIF file.
will start scanning the file to determine the formats used to represent dates and numbers. In case it cannot determine a date format unambiguously, will ask the user to select one from the list of possible date formats.
Next, imports the data and creates all necessary objects, such as payee information, accounts and category records, and stock price information. Wherever possible, existing transactions will be matched against the imported information. A progress bar is shown and updated during the import process.
In case could not detect the name of the account to be imported, the user will be asked to select the account into which the data should be imported. If the account does not already exist in your file, a new account can be created by clicking on Create.
At the end of the import, shows a statement import statistics window.
Statement statistics
Statement statistics
After importing, all of the imported transactions will be shown with a yellow background in the ledger view. In case was able to match an imported transaction with an already existing transaction, the background is shown in light green.
The next step is to verify the imported data and accept it. This is a general process and also applies to imports from other sources. It is outlined in a separate section of this document.
The colors used to mark imported and matched transactions are customizable and may be different in your environment.

Importing Investments
Please note that if you are importing a file with investment transactions, you should first check your import file, to see if the investments are detailed in "!Type:Security" records containing the security name and symbol. If so, should be able to set up the appropriate accounts for you. If not, however, you must first create those accounts before importing. See separate section. The trading symbol is used for matching, so, if the investment already exists in please ensure that the symbol in is exactly the same as the one in the file you're importing.

Setting up a QIF profile
Because there is no universally standard format for a QIF file, different vendors have taken liberties with the format, and introduced their own nuances. The QIF Profile allows to know about the peculiarities of your file. To edit an existing QIF Profile, or to create a new one, press the New button on the QIF Import dialog, near the profile selector.
QIF Profile Editor
Previous versions of used to have a tab for date and amount specifications. now determines those settings by scanning the file. If it cannot figure out all settings, it will interrogate the user during import.

Transaction matching
As noted previously, one of the major drawbacks of the QIF format is the lack of a unique identifier for each transaction. Thus, if you import a QIF file and some of the transactions are already in your ledger, you may get duplicates. attempts to get around this by looking for transactions that look similar to those you already have. If it finds something that looks like the same transaction, it will match the apparent duplicate.
This can be a problem if you have transactions that look too similar but are actually different. In this case, you can unmatch those transactions later in the ledger view.

Writing an import filter
Sometimes you may have data in a custom format, like comma-separated-values (CSV), or something else unique to your situation. While a CSV import plugin has been added to , you can still import a custom format file into using a QIF Import Filter. A filter is a custom program you write which takes your special file as input, and produces a QIF file as output. This can be a shell script, a perl script, a compiled program written in C/C++, or anything else you can dream of, as long as the system can run it.
To use it, edit your favorite QIF Profile, and select the Filter tab. Enter the location of your filter program where prompted. Then, whenever you do a QIF import using this profile, the file you select for importing will be run through your filter first.
A common problem is to convert a list of comma-separated-values into a QIF file. This is a textbook case for the awk tool. Create a script called csv2qif.awk, with the following two lines as contents:

	BEGIN { FS=","; print "!Type:Bank" }

	{ print "D"$1; print "T"$2; print "N"$3; 
          print "P"$4; print "M"$5; print "^" }

Then, change the QIF keys (D,T,N,P,M) to match the order of your csv data. Set the input filter to awk -f csv2qif.awk.
Another problem sometimes arises in the encoding of QIF files. expects files to be UTF8 encoded. If your file is encoded in something else, it can be useful to convert it to UTF8. For example to convert it from iso-8859-1, you would set the input filter to recode iso-8859-1..utf-8.

Special QIF extensions
As already mentioned, one of the major drawbacks of the QIF format is the lack of a unique identifier for each transaction. If you are writing your own QIF file creator (or filter, as described above), you can overcome this problem. supports the '#' field. The importer will interpret this as a unique transaction ID, and disregard the record if the transaction is already in the system.

QIF Exporter
To export one of your accounts to a QIF file, choose the Export QIF from the File menu. You will be prompted for which single account to export, what file to export it to, and what QIF Profile to use.
At the moment, QIF Exporter does not handle export of investments.

QIF Export

OFX Importer Plugin

Getting the plugin
will import OFX files painlessly. This functionality is now provided with the core program. The command to import OFX files will automatically show up under the File Import menu.
Note that many prepackaged versions of were built with the OFX importer already included or available as a separate package. If the OFX importer does not seem to be installed in your version, the first place to check is in the same place you got your base package.
If you have installed from RPM, the OFX Importer Plugin is contained within the kmymoney-ofx RPM. It should be available from whatever source you got the base RPM. If you have built from sources, all you need to do is have preferably the libOFX 0.9 development headers and libraries installed on your system. The build process will detect these and compile the plugin. libOFX 0.8.2 is supported as well, but some features are not supported with this version of the library.
Should you run into trouble trying to compile , and you are certain you have the correct version of libOFX installed, please contact the developers list for assistance. Include a copy of your config.log file, compressed first via gzip.

Importing an OFX file
The most basic way to import an OFX file is to choose the importer from the menu bar. From the File menu, choose Import, and then OFX. If OFX does not show up under Import, you do not have the OFX Importer Plugin installed correctly. Please see the previous section.
The first thing the importer will do is ask you into which account to import the transactions. If there are transactions from multiple accounts in your file, you will be asked this question multiple times.
After importing, some of your transactions may be shown with an exclamation mark on a yellow triangle in the ledger. This is because they need to be assigned a category. The importer was not able to automatically assign a category based on your past transaction history. You can edit each transaction in the ledger to assign a category, and the mark will be removed.
Please note that this section describes the native OFX importer. OFX files may also be imported using the AqBanking Importer Plugin if you have installed that. Note that the two importers do behave slightly differently, and they are written and supported by two different developers.

Importing Investments
Please note that if you are importing a file with investment transactions, those investments must first exist in your file. The trading symbol is used to match, so please ensure that the symbol in is exactly the same as the one in the file you're importing.

Web Connect
The easiest way to import an OFX file is to set up Web Connect. Visit your bank's web site, and click on a link to download an OFX file. Your browser should ask you what program you would like to use to open the program. Point your browser to . It will then import the downloaded OFX file into the file you most recently had open. You can also change the file associations of your desktop environment, and have open the OFX file automatically for you.
If you need to import the OFX file into some other file, load up that file in first, and then visit your bank's web site.

Direct Connect
OFX Direct Connect is now supported in . This gives you the ability to contact your bank directly to obtain statements. In the future, there will be more help written, and this will be moved to its own section.
To enable this feature, you must compile with the --enable-ofxbanking switch (now the default).
Please be warned: Many banks require a separate signup, will give you a separate password or PIN, and may even charge you a separate fee for this service. No bank directly supports . You will have to tell them you want to bank directly from MS Money or Quicken.
The first step is to configure each account for which you wish to download statements. Go to the Accounts view, right click on the account you wish to configure, and choose Map to online account.... In case more than one online banking plugin is installed on your system you will be asked which one to use. For the internal OFX method select KMyMoney OFX. A list of banks will be downloaded from the Internet and a wizard will guide you through choosing a bank, entering your username and password, and selecting an account. Should you find that your bank is not listed, then it may still be possible to use the manual option. Your bank may be able to provide the required parameters, or you may have to do some research to find them.
Once you have an account set up with online banking, go to the ledger for that account. Then from the Account menu, choose Update account.... This will connect to your bank, and download a statement for the last 60 days.

Exporting an OFX file
It is not possible to export your data as an OFX file currently. If you are interested to contribute in this area, please contact the libofx development team for details.

CSV Importer Plugin

Introduction
The purpose of the plugin is to import CSV format files into KMyMoney. Its primary focus is on importing bank statements, but there is also a capability to import some investment statements. It retains its initial ability also to produce QIF files from CSV. A well-known drawback of QIF format is that it is a fairly loose format. With CSV files, there is this same problem, only more so, in that there is no agreed standard at all. With investment files, in particular, there is much more scope for variation in specifying investment activities. I've tried to handle this by having these activity types listed in a resource file - csvimporterrc (usually found in ~/.kde4/share/config/, but may be in .kde/... instead, in Ubuntu and possibly other distros), allowing the user to add any that I haven't encountered. The plugin itself contains a few of the more obvious descriptions.

How to import a CSV file
Much of the CSV import process is similar to QIF file import, so it might be helpful to read that section as well.
To import a CSV file, first ensure you have a valid file open. Then select Import CSV from the File menu.
First startup. On first startup, the CSVImporter can open without its csvimporterrc resource file, and will create one on closing. For further details, see below.
Banking. This is fairly straight-forward. When the CSV importer has loaded, select the Banking tab, and click Open File and select your input csv file. Your file will then be displayed. If the fields are incorrectly displayed, select the Settings tab and choose the correct field delimiter character. The file should now be displayed correctly. Back on the Banking tab, select the columns corresponding to your data format. If your file has just a single column for the amount, click the Amount radio button, then the appropriate column number. Or, if there are two columns - debit and credit - click the Debit/credit radio button, then select the appropriate columns. If a mistake is made, just re-enter the correct column number. Alternatively, click Clear selections to clear all the selections and try again. If you wish to save more than one field as the memo field, just select those columns sequentially. If you inadvertently attempt to select the same column for two different fields, the plugin will detect this. Because it cannot know which one is correct, it will output an error message and clear both selections, allowing the error to be corrected.
Now select the Settings tab. Here, ensure the field delimiters are set correctly. Now select the start line for input, allowing any header lines to be dropped. The last line will have been set to the final line in the file, but if there are trailer lines, select the correct last line. Now, when you select the Decimal Symbol to use, the appropriate cells will be highlighted in green, assuming no error was detected. Finally, ensure the correct date format is selected, to match your file. The display will update, and once you are happy, click Import. will now display a selector dialog box for you to choose the correct account into which to import the file. It is possible at this stage to save to a qif file, should you require one for any reason.
Investment. Click on Investment tab at the top, and then follow a similar procedure to the above. The Type/Action column is where the activity is described - buy, sell, reinvest, etc. The Price Fraction setting is for matching the imported pricing units with the existing pricing, where for instance one is in $ and the other in cents, or £ versus pence, etc. For example, if your data file pricing is in dollars, and so is the CSV file, then set Price Fraction to 1.0. If however, the CSV file pricing is in cents, set the fraction to 0.01. Select the fee column according to whether any fee is involved, and click the Fee is Percentage box if the imported fee is a percentage rather than a value.
Just a warning here. It may be that the fee has been taken into account in the unit price. If so, don't select any fee column, although any fee shown may be imported by selecting the fee column as another memo column.
Then, enter the name of the security, ensuring it matches the existing security. If the security name appears in the imported file, double click on it, then copy and paste/edit to match. Security names are saved in the resource file, so in the future security names may be selected from the drop-down list. Should an erroneous entry have been made, select it and click Hide security to remove it from the list kept by the plugin. This has no effect on the securities within .
Next, click Import. If any transaction involves another account - eg. a checking or Brokerage account for a received dividend or for making a payment, etc., a message box will pop up for the account name to be entered for the transfer. If the investment account allows for, say, writing cheques, you may enter an existing checking/brokerage account name. Similarly enter the column number containing the payee, if requested. If a mistake is made when entering the account name, the import will go ahead, but will not recognise it, and will flag those transactions as missing an assignment. If the required account name is rather long, just enter a few characters. You can select the proper checking or Brokerage account name in the selector dialog. However, the transactions will be flagged by as missing an assignment, and the correct transfer account will need to be selected after import.
If, during import of a transaction, the plugin finds no valid action type, it will display the offending transaction, and the user may select a valid type to substitute, depending on the combination of quantity, price and amount values. For every transaction, it will validate the column contents to ensure they match the action type. For instance, if a quantity appears but no price or amount, it is assumed that the transaction can be only an add or remove shares. If you find that your investment statements keep including activity types that are not recognised, just add them to the fields in the resource file. For instance, in the [InvestmentSettings] section, the BuyParam field includes entries for Purchase, Buy, New Inv, and Switch In. If you find a different one, add it to the right list and restart the plugin. You may notice that there are similarities in the entries in different fields, and you may find that the wrong activity type is being selected. The program checks these lists in the following order - Shrsin, DivX, Reinvdiv, Brokerage, Buy, Sell, Remove. I've tried re-ordering the lists to suit this, but I've found that the entries in the resource file get sorted into alphabetical order. If the offending parameter is one you don't need, just delete it. If that's not possible, you may need to edit your file before input. Just another warning here. It may appear that the displayed entries may be edited, and in fact they they may, but the edits are not kept. The display is purely for display, not for editing. The input file is never altered by the plugin.
I've provided a couple of sample csv files (in the kmymoney/contrib/csvimporter/ folder) in the hope that they may help. For example, in the investment sample, an activity type is "ReInvestorContract Buy : ReInvested Units". In the validation process, the first successful match is on the ReInv in ReInvestorContract Buy, so the transaction therefore gets classed as Reinvdiv, even though Buy also is mentioned. Another example I've seen was an activity type of Reinvest even though the transaction included neither price nor amount, but only a quantity, so that needed to be treated as Add Shares, or Shrsin.
I've only seen a few investment formats, and it may well be that you will encounter one which cannot be handled correctly. If you send a suitable (edited) example to the list, I wll do my best to handle it.

Writing Importer Plugins
contains explicit support for importer plugins. If you have a custom format, and you would like to write an importer plugin, we would value your contribution. To do so, you'll need to compile the program from source. Then use the OFX Importer Plugin as an example.