Friday, October 16, 2020

Balance statement extractor and stitcher - Python

Place your bank statements into statements folder (C:\balancemerger\statements) Run this program to extract only the first page with "Balance" case sensitive match from each pdf Then stitch the extracted PDF into a new document in "C:\balancemerger\output\" folder

Wednesday, June 8, 2016

Winning GuessTheCorrelation.com machine assisted

This method is not suggested as it takes the fun out of guessing in the game.  However it was fun for me to write the R program to guide when you are in the verge of losing :-)

Here is the algorithm:

1. Save the snapshot of image into a PNG file
2. Read the file using R library as a matrix
3. Convert the image to grayscale
4. Flip the image Horizontally
5. Convert into a binary image with threshold 0.99999.
6. Apply thinning algorithm to the matrix
7. Apply R's cor function to get the correlation from the matrix
8. Print it
9. Use it :-)

Here is the program:




Note: I spent 3 hours and learnt some amount of R just for this stint.  So the program might not be efficient.


Here are the custom functions:

Thursday, May 7, 2009

How did I write my own macros for web scrapping from KodakGallery.com?

I remember the following always, "Give a man a fish, he will not be hungry for the moment. Teach a man how to fish, he will never be hungry".

So in this blog we will see how to write macros using firefox using an example. The example is how to write a macro which you could use to shift all your photos in original quality from KodakGallery to Local drive/disk.

Items needed:
1. Firefox 3.0 or above (http://www.mozilla.com/firefox/)
2. iMacros for firefox (https://addons.mozilla.org/en-US/firefox/addon/3863, Click "Install now" and then select the add-on from the dialog box and click "Install now" button. Restart firefox, once.)
3. MeasureIt (Goto https://addons.mozilla.org/en-US/firefox/addon/539, Click "Install now" and then select the add-on from the dialog box and click "Install now" button. Restart firefox, once.)

For the Do-It-Yourself folks:

Here are the detailed steps you should follow,
1. Open a new firefox window.
2. Visit "http://www.kodakgallery.com/"
3. Click SignIn
4. Enter your E-mail address/mobile number and password and click "Sign-in"
5. Click "My Photos"
6. Click on one of the albums from which you need to download all the photos.
7. Click on the first image in the album
8. Click on the "iOpus iMacros" button, located beneath the menu bar. You should see a "iMacros" frame.

9. Click "Edit" tab in "iMacros" frame

10. Click "Options" button in "Edit" tab

11. Click "Paths" tab in the "Options dialog

12. Change Folder Downloads, to any folder you wish. Click "Apply" after the folder changes
13. Click "Rec" (Record) tab
14. Click "Click Mode" button in the "Rec" , select "Use X/Y position" radio button and click "Ok"
(Buckle up. We are ready to record the macro. :-) )
15. Click "Record" in the "Rec" tab. Now we are in the recording mode.
16. Context click (Right click for windows users) on "DownloadDownload high-resolution " link, select "Save link as", select the folder in which you need to save the JPG (same folder which you selected in Step 12) and click "Save"
17. Click on the "next" navigation button
18. Click "Stop" button in the "Rec" tab of iMacros frame
19. Now click MeasureIt tool in the bottom-left part of the browser's status bar. You should see a layer of brightness painted over the browser view panel.
20. Now you have to measure the width and height of the "Download" link. To do that, click on the link and drag your mouse towards top-left and make a note of the width and height. For me it was height=525 and width=568. I guess this value might vary based on your resolution.
21. Click "Edit" tab (by default our current macro named "#current.iim" would be preselected in the List box of the iMacros frame, if not, select it)
22. Click "Edit Macro" button of the "Edit" tab
23. Now the macro would have been opened with a file editor (for me it opened in Notepad).
24.
a) Delete the line that looks like "URL GOTO=http://www.kodakgallery.com/PhotoView.jsp?..."
b) Look for a line "CLICK X=undefined Y=undefined CONTENT=EVENT:SAVETARGETAS". Change it to "CLICK X=525Y=568CONTENT=EVENT:SAVETARGETAS"
25. Save the file and closer the file editor.
26. Now goto "Play" tab
27. Enter the number of photos you are yet to download in the "Max" textbox (it should be N-1, where N is the total number of photos in your album, considering you have already downloaded one)
28. Click "Play (Loop)"

That's it folks. Now you know how to write a iMacros yourself. Happy web scrapping.

Wednesday, May 6, 2009

Transfer High Quality Pictures from Kodak to Picasa

In this post, I'll let you know on how to automate the transfer of your photos (in original quality) from Kodak to Picasa.




Lately each of us would have heard that Kodak has changed its policies and has mandated to make atleast a minimum purchase every year so that they would maintain your photos in their system. Some of us (including me) would have thought, why should not I move my photos from
Kodak to Picasa (which is free as of now). Yes, you could do that in an semi-automated way, by following the steps below. I thought of fully automating it, but the global meltdown has showered a few other important problems on me, which I have to work0ut now!

Okay. Let us get our hand's dirty now. You would need the following, which are all available for free and if you are computer enthusiast you might already have it!

Items needed:

1. Firefox 3.0 or above (http://www.mozilla.com/firefox/)
2. iMacros for firefox (https://addons.mozilla.org/en-US/firefox/addon/3863, Click "Install now" and then select the add-on from the dialog box and click "Install now" button. Restart firefox, once.)


Basic Strategy

1. Get all the photos in a album from Kodak to a directory in your local computer, using macro
2. Upload all the photos to Picasa
3. Repeat the above steps for all your albums


Setup steps

Note: If these steps do not work. Then follow the steps that is mentioned in the youtube video below.




1. Create a file as detailed below (Note: My earlier approach of choosing file based on resolution won't work, as there is another factor [zoom], which could change the cartesian co-ordinates under consideration!. If you don't understand the note, just ignore it, it is written for the sake of the people who post the valuable comments, which made me rethink the whole approach. Thanks anonymous commentors. :-) )

Save the snippet 1 below as "C:\FromKodak\macro1.txt" using notepad.

Snippet 1:
VERSION BUILD=6210326 RECORDER=FX
TAB T=1
ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES
CLICK X=[##Number1##] Y=[##Number2##] CONTENT=EVENT:SAVETARGETAS
CLICK X=[##Number3##] Y=[##Number4##]

[##Number##] will be substituted with numbers based on the steps mentioned below.
a. Click "Click Mode" button in the "Rec" , select "Use X/Y position" radio button and click "Ok"
b. Open a new firefox window and visit "http://www.kodakgallery.com/"
c. Enter your E-mail address/mobile number and click "Sign-in"
d. Click "My Photos"
e. Select the album from which you need to download all pictures. You will see picture list in the album
f. Click on the first picture in the picture list
g. Goto "Rec" tab and click "Record. Now we are in the recording mode.
h. Click on "Download high-resolution " link
i. Click on the "next" navigation button
j. Click "Stop" button in the "Rec" tab of iMacros frame
j. Goto "Edit" tab and click "Edit Macro" button. You would see something like this in new iMacros editor window (Say MacroEditWindow).
...
CLICK X=704 Y=569
...
CLICK X=987 Y=159




Now substitute the above four numbers in "c:\FromKodak\macro1.txt". You would get

Snippet 2:

VERSION BUILD=6210326 RECORDER=FX

TAB T=1

ONDOWNLOAD FOLDER=* FILE=+_{{!NOW:yyyymmdd_hhnnss}} WAIT=YES

CLICK X=704 Y=569 CONTENT=EVENT:SAVETARGETAS

CLICK X=987 Y=159

2. Substitute the existing macro in "MacroEditWindow", with content of "Snippet 2".

3. Click "Save & Close"

Now we have created a macro which now can download pictures in an album automatically. Now with just one click you could download all pictures in an album. So if you have 5 albums and each album has 200 pictures (totally 1000 pictures), you just click 5 times, viola your pictures will be in your local drive/disk. Look into steps below for running the macro once for each of the albums.

Look into YouTube video below for more clarity.



Download all pictures in an album to your Computer in three easy steps

1. From logged in KodakGallery.com site opened in Firefox browser, click on the album you wish to download from the album list (How do I do this)

a. Open a new firefox window.

b. Visit "http://www.kodakgallery.com/"

c. Click SignIn

d. Enter your E-mail address/mobile number and password and click "Sign-in"

2. Click on the first picture in the picture list of the album you are interested in.
3. Enter the number of photos you are yet to download in the "Max" textbox and click "Play (Loop)" button.

Where are my saved photos?

1. Click "Options" button in "Edit" tab

2. Click "Paths" tab in the "Options dialog

3. Look into "Folder Downloads" textbox value. That is the folder where-in you have all your files.

Tip: After everytime the macro is run, create a new folder and move all the harvested photos into the new folder. This way you could keep your photos organized by folders. Without doing this, all your album photos will be in a single folder and it might be a headache later to sort them out.

Now that you have got all the files in your local drive/disk, you could move it to Picasa as usual.

Lesson learnt:

The lesson learnt from KodakGallery policy change is that, use online services just to share media files and information. Things that are closer to your heart, should be closer to you. I mean, have back-ups on optical disks and you will not be worried, about the policy changes.

Any issues or do you want to share something? - post as comment
Feel free to reach me,
if things does not work, or you would like to know how to do write the macro and retrieve the photos from KodakGallery yourself, post your requests through comments.