Thursday, April 28, 2011

Export MS Access Memo field and convert Unicode

I have an Access 2003 database. A table has a Memo field and I'm having issues with getting that data out.

  • Exporting that field to a txt or csv chops that field off (255 characters)
  • Exporting as Excel gives me strange characters for linebreaks
  • Appending to a mysql database via myODBC gives an error about "incorrect string"
  • Using VBA with Scripting.FileSystemObject doesn't work unless you tell it to create the file as Unicode, which is okay, but then I can't get the file converted to something I can import

There are Unicode characters in some of my data. It's not a multi-linual database, so the only ones I can find are slanted quotes, probably copied in from Word. Dropping them is fine; the information in the fields will still be understandable.

Can I convert these Unicode characters to their (ANSI? ASCII?) equivalents? I've not dealt with encodings very much.

I tried playing around with iconv, but without knowing anything about the encoding, it didn't really help.

Right now, I need help on: - converting the characters in my database so they export non-unicode-ish-ly - OR, converting the unicode characters after the file has been exporting.

From stackoverflow
  • Export to .xml

    wesgarrison : ... which still exports with the wacky leading Unicode character.
    Jeff O : Can you post this character in a comment?
    Jeff O : I can't get half credit for at least including more that 255 characters?
  • The file created by Access/VBA is UTF-16. For some reason, there is a character at the beginning of the file that was causing the Ruby YAML library to parse wrongly.

    iconv to the rescue!

    iconv -f UTF-16 -t ASCII -c utf_file.yml > ascii_file.yml
    
  • How are you exporting? Have defined an export spec? In Access 2003, this gives you a dropdown list with all the usual encodings (code pages), including Unicode UTF8. This is also how you define your memo field as having a length greater than 255 characters.

    wesgarrison : I'm writing individual lines to a text file with FileSystemObject and writeln(). If I were using TransferText, then an export spec would be the way to go for sure.
    David-W-Fenton : Where are you running your code? Withing Access? If so, I'd suggest you would be better off with TransferText, precisely because it handles the problems you're having.
  • how to show unicode from mysql in the crystal report

0 comments:

Post a Comment