Friday, February 24, 2017

Pandas Workaround of CParseError: Error tokenizing data. C error: EOF inside string starting at line

This week I posted a bit different post than my previous posts. Originally I was writing this in stackoverflow.com. However, before I posted my question, I made sure that I have already tried every options that might solve my issue. And it turned out that my last attempt worked! So I declined to post this in stackoverflow.com. Nevertheless, since I thought that I might need to re-look at this workaround in solving the CParseError in Pandas, thus, I decided to post it in my blog.

I would like to read a csv file using Python 3.5 and Pandas 0.18.1.
import pandas as pd
df = pd.read_csv(directory, skiprows=3)
However, I got the following error.
CParserError: Error tokenizing data. C error: EOF inside string starting at line 353996

Friday, February 17, 2017

Python Graphical User Interface (GUI) Using PyQt5: Basic - Part 1

I am not a big fan of GUI. I do not like developing the front-end of the program. For me, personally, developing the back-end of the program is more fun. However, if you are the only developer in a company, or in my case the only data scientist in my company, then developing a GUI is a must. Why? Because nobody gives a sh*t about the back-end. What they want is something that they can interact with, something that is "beautiful", and the final result.

General overview of the whole structure of the program

Sunday, February 12, 2017

Measuring the dimension of an object using OpenCV and Python:SOLVING The Bugs!

Just a quick review, here are the list of parameters that we need to manually pass to our program. Without any of these parameters, our program will not run. So here they are:
  1. Working directory
  2. a set of suffixes of the image filename
  3. coin's diameter and the measurement unit
  4. width of the resized image
  5. rotating angulation
  6. Gaussian kernel size
  7. minimum and maximum value of Canny Hysteresis Thresholdings
  8. iterations of morphological transformation

Saturday, February 4, 2017

Measuring the dimension of an object using OpenCV and Python:BUGS!

BUGS detected!


As you may see from the figure above, rather than detecting the coin as the first object, the program "think" that that "something" on the picture is the coin. Therefore, all the measurement is completely wrong.

Friday, January 20, 2017

Measuring the dimension of an object using OpenCV and Python: MAKE AN EXECUTABLE (.exe) FILE FROM THE PYTHON SCRIPTS (.py) USING PyInstaller

The next day, I came to the lab with a very proud feeling of myself, because I have finished the code to measure the mechanoreceptors' dimensions automatically. I greeted everyone in the lab and did a short demo of how the program works. Finally, I enclosed the demo with some notable limitations of the program.

Everything went well until that point. However, it was not always sunshine and rainbows on the garden when you are facing an end-user.

After the demo was finished, one of my labmates said, "Wow! Great! Thanks! Now please install this in my computer." Then I said, "Okay! Fine! You just have to download the Python3 or Python2 from the python website. And then install it. After that  you need to install the required libraries or packages, such as numpy and opencv, in your computer as well."

Then I realized that as an end-user what I just said was so confusing. At the end of the day, she said to me, "Wow sounds so complex. Please do help me install them in my computer."

Long story short, I installed everything in her computer. Then I showed her how to run the program. "You just have to put the images together in a folder. Copy and paste these python scripts into the same folder as before. Then go back one folder. Now click on the folder. Press shift and then right click on the folder. Lastly, click 'Open command window here'. Afterwards, you need to type: 'python measure_object_dimension.py'. Bam! The magic's happened!"

If you were in her shoes, what do you think and feel? I bet you will be as confused as her and also you will not be able to remember every step that you need to take to run the program. That was exactly what she said to me after my step-by-step explanation, "Could you please make it simpler? Like I just have to double-click on an icon then the program is running automatically."

I was baffled. Never heard of converting a .py file to .exe file. Nevertheless, thanks to Google and Python community! Just by a simple googling I found so many alternatives to convert a .py file to an executable file in windows (.exe).