Wammu2cvs HowTo

I started writing the perl after I dicked around a bit with the file. The file is by default DOS formatted, illegible and apparently encoded in utf-16. Since I first wanted it as a reference (to grep, cat or less in a term window) so I did the following. You ll have to do this too (do feel free to submit the Perl code in the comments to skip this part ;))

Convert to UTF8 - using vi

  • Open the file using vi.
  • Save file (yes, save BEFORE editing, this converts the binary to a regular file)

    :w ConvertMe.txt

    • If the conversion using vi doesnt work for you, you can also use flip (Thanks to AK for the tip, check his comment for more info!)

      flip -ub ConvertMe.txt

  • Set unix encoding

    :set ff=unix

  • Reset the encoding

    :set fileencoding=default

  • Save! (use the :w)

Convert to UTF8 - using recode
DBLaci used the program ‘recode’ to convert the utf-16 file. recode converts in place.

recode utf-16..utf-8 bla.backup

It wouldnt be too bad writing this in the perl code.. ;)

Next

Next part is the Perl script. (The code is after the jump..)
The script reads a file called ConvertMe.txt - You can change this in the script, but really, why :)

  • run convert.pl , this will output the .csv on the screen
  • run convert.pl > converted.csv to get the google ready csv..

What if this doesnt work?
There are three options for output..

You ll find the following in the code. Its not that long, do a search ;)

# Print de codes?
my $codes = 1;

to print all the codes in the file you re having parsed. This reads the file and spews out all the different tags in there in an easy list.

# Print de raw data
my $raw = 1;

Print the raw data. Prints all the tags for every contact, so you dan easilly check if all looks right

# Print de geparste code
my $parse = 1;

This is enabled by default. This option parses all your data into the .csv format.

If the last fails, its possible you need to change or add to the tags described in the .csv file. This defenition starts at line 66, the # Parse data line. First check what tags your file provides by setting the $codes option and then fill these in on the right lines in the script. Dont remove the commas or the .csv will fail to parse correctly. Just add the fields in front, analogous to the current settings. Dont worry about the tags that wont be filled, they will be empty.
Dont worry, it ll work ;)

More about me

Site QR Code

Use this code at your own peril; I am not responsible for anything that happens to you or your devices. You re a big boy or girl, please do some research before using it if you have any concerns!