Come on Python! Just Read My Clipboard

I don’t know whether you guys have been annoyed by the MyStatLab powered by Pearson. These days I was busy doing homework on it. My homework is about statistics analysis and it requires to use a lot of work on RStudio. However, as everybody know, R doesn’t support xls format very well, which requires users to transform the xls file into csv file first.

It might not seem to be a big deal as long as you have the csv file that is quite ubiquitous among data world. Nevertheless, MyStatLab doesn’t provide the csv format and give users the access of xls format instead! It gives the user to options: one is to copy the datasheet to the clipboard; the other is to download it as an Excel file.

This was totally nightmare when I tried to do my work on MyStatLab. Since I want to avoid uncertainties of reading a txt file in RStudio(which means I have to copy and paste the data to a txt file and you know we can’t simply modify the “.txt” to “.csv” because it won’t work!), I have to download the Excel file, open it in Excel, save it as a csv file, read and open it in RStudio. Those are all repetitive work and quite time consuming and not pleasing.

Screen Shot 2015-09-14 at 10.28.18 PM

After finishing my job painfully and stupidly, I calmed down and tried to solve it in Python. I hate all repetitive work and I believe machine should have done it better. Therefore, I wrote a small program to read my clipboard and save it as a csv file.

P.S. I did consider to read the excel file and run a python program save it as a csv file but I don’t see the boost in efficiency comparing to copy the data and run the python scripts. Another reason to do that is because creating a csv format file is supported originally by python.

Here are the codes:

I refer to http://stackoverflow.com/questions/16188160/how-to-read-data-from-clipboard-and-pass-it-as-value-to-a-variable-in-python and it is quite useful and block the Tkinter window to pop up automatically. Also, I added the support for UTF-8 encoding because I am afraid that I might use it to convert some csv files where headers would contain some Chinese characters.

2 Comments

  1. seo fiverr says:

    My partner and I stumbled over here different web page and thought I might check things out. I like what I see so now i’m following you. Look forward to going over your web page repeatedly.

  2. “I’ve learn a few excellent stuff here. Certainly price bookmarking for revisiting. I wonder how a lot attempt you place to make this sort of wonderful informative web site.”

Leave a Reply

Your email address will not be published. Required fields are marked *