Need to add an option to support CSV files in different encoding systems

53 views
Skip to first unread message

FuguTabetai

unread,
Jun 1, 2012, 9:19:04 PM6/1/12
to mdcsvimporter
By default it looks like you are creating Readers based on
FileReader( File .. ) which uses the default character encoding for
the platform. For Macs, that is usually MacRoman (although you can
change it by editing the Info.plist to add the file.encoding property
under the java section and setting that to e.g., UTF8) which will
garble the text on some file in a different encoding. Ideally there
would be an option to select an encoding (text box would be fine, or
even a select with a few common ones.) Then you can change the code
to something like the below:

ImportDialog.java
From CSVReader cvsReader = new CSVReader( new
FileReader( selectedFile ) );

to

String encoding = encodingInput.getSelectedEncoding(); // Return a
String or Charset
CSVReader cvsReader = new CSVReader( new InputStreamReader( new
FileInputStream( selectedFile), encoding ) );

The same thing holds for TransactionReader.java

Actually, even better would be to use the Charset object to get a list
of all supported character sets, dump those into a menu, preselect
UTF-8 (because all text should be UTF-8) and let the user choose from
that. http://docs.oracle.com/javase/1.4.2/docs/api/java/nio/charset/Charset.html

I guess I could make these changes too if that would be useful. I
would have to set up Eclipse to read from this subversion repository
(I haven't used Eclipse or subversion at home for a long time, we use
P4 at work) but I should be able to do that at some point.

fugu

FuguTabetai

unread,
Jun 2, 2012, 9:39:31 AM6/2/12
to mdcsvi...@googlegroups.com
I have checked out the SVN source (read only) and downloaded the moneydance SDK from http://moneydance.com/developer.  I have a problem though: it looks like the version of the moneydance JARs I am including (extradmin.jar, moneydance.jar) are old versions or something.  I get the following errors:

Description Resource Path Location Type
Can only iterate over an array or an instance of java.lang.Iterable TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 210 Java Problem
The method getAllTxns() is undefined for the type TransactionSet TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 254 Java Problem
The method getAllTxns() is undefined for the type TransactionSet TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 257 Java Problem
The method getFIID() is undefined for the type OnlineTxn TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 441 Java Problem
The method setIsNew(boolean) is undefined for the type ParentTxn TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 553 Java Problem
The method setIsNew(boolean) is undefined for the type SplitTxn TransactionReader.java /moneydance csv importer/src/com/moneydance/modules/features/mdcsvimporter line 550 Java Problem

I can't find any other SDK version to download.  Is Developer's Kit 2.2 what you guys linked against?  I would like to add a menu to select encodings to the cvs importer, but if I can't get the extension to compile I don't see how I can proceed.  Thanks in advance!

stashu pub

unread,
Jun 2, 2012, 4:50:21 PM6/2/12
to mdcsvi...@googlegroups.com

Hi,

My laptop died and I have note been able to look at the code in maybe a few months. i have changes in the works on my pc that I have note been able to finish until recently. I just got a new laptop.

So, we will have to work with merging out changes, or you can look at it and wait until I get a chance to post my code to svn.

If you want to work on the encoding functionality that would be fine. I would rather your do it the better way than we just give a few hardcoded options.

Let me know.

Thanks,
Stan

--
You received this message because you are subscribed to the Google Groups "mdcsvimporter" group.
To post to this group, send email to mdcsvi...@googlegroups.com.
To unsubscribe from this group, send email to mdcsvimporte...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mdcsvimporter?hl=en.

FuguTabetai

unread,
Jun 4, 2012, 7:26:37 AM6/4/12
to mdcsvi...@googlegroups.com
Could you tell me the exact version of extradmin.jar and moneydance.jar that you use?  The versions above do not allow me to compile the SVN head version as it stands.  

fugu
To unsubscribe from this group, send email to mdcsvimporter+unsubscribe@googlegroups.com.

FuguTabetai

unread,
Jun 5, 2012, 9:31:23 AM6/5/12
to mdcsvi...@googlegroups.com
thanks for the email with the libraries.  I've now made the changes I want, and have tested them locally. 

fugu

stashu.pub

unread,
Jun 5, 2012, 8:41:33 AM6/5/12
to mdcsvi...@googlegroups.com
Hi,

Can you send me the files you changed?

Thanks,
Stan
To view this discussion on the web visit https://groups.google.com/d/msg/mdcsvimporter/-/IRfmMLx4-nEJ.

To post to this group, send email to mdcsvi...@googlegroups.com.
To unsubscribe from this group, send email to mdcsvimporte...@googlegroups.com.

Fugu Tabetai

unread,
Jun 5, 2012, 6:54:23 PM6/5/12
to mdcsvi...@googlegroups.com
Sure.  I'll attach a diff, and the two changed files.  

You'll have to merge the GUI changes I did by hand into your Matisse form file, but otherwise the changes should be straightforward.  It at least let me import my data from my bank!  

I might fool around with creating a reader for the Tokyo Mitsubishi UFJ CSV format, since they also include the remaining balance with every entry, which the custom reader doesn't seem to have a field type for.  I also don't understand the difference between Normal / Online import types, so I'll look over that code. 

Let me know if you have any questions!

Fugu
encoding.diff
ImportDialog.java
TransactionReader.java

stashu.pub

unread,
Jul 1, 2012, 2:12:33 AM7/1/12
to mdcsvi...@googlegroups.com, FuguTabetai
Hi,

I was without a laptop for a long time and then have had a new job
and no time to work with mdcsvimporter, but lately i might have a
little time.

I use netbeans 7 and I looked at this tonight, but it will take more time
as I will have to play with probably creating the new field on the panel myself
since you gave just the java file and not the .form file that goes with it.

I wonder if picking a fileformat could be different per reader config, or just
on the main screen/importdialog where I think you put your new field?
If it might really be different between readers, then I should put it on the
'manage custom readers' screen.

Online is probably better to use. It is a more temporary transaction.
You would have to look at the detailed xml text and read the api to
figure this one out !

Stan
Fugu

To unsubscribe from this group, send email to mdcsvimporte...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mdcsvimporter?hl=en.

--
You received this message because you are subscribed to the Google Groups "mdcsvimporter" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mdcsvimporter/-/IRfmMLx4-nEJ.
To post to this group, send email to mdcsvi...@googlegroups.com.
To unsubscribe from this group, send email to mdcsvimporte...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mdcsvimporter?hl=en.
--
You received this message because you are subscribed to the Google Groups "mdcsvimporter" group.
To post to this group, send email to mdcsvi...@googlegroups.com.
To unsubscribe from this group, send email to mdcsvimporte...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mdcsvimporter?hl=en.
Reply all
Reply to author
Forward
0 new messages