Rob Cheng's Blog

Importing CSV’s using PHPmyAdmin

When working on the photo part of my web site, which is a many-to-many database layout, I recently ran into the following frustration. I have found that it is much easier to manipulate my tables in Excel, and then uploading the resulting CSV back into MySQL. But I kept getting a wide variety of errors stating that I had an error.

invalid field count beginning in line XXXX.

Here is a link to one of many people having the same problem.

http://www.phpbuilder.com/board/showthread.php?t=10328310

There are actually two bugs in Excel that are causing invalid field counts. Check out this link:

http://support.microsoft.com/kb/77295/en-us#appliesto

The issue arises when the last column has blank fields in it. That was certainly the case with me. The trick is to place at least one character in each row of the last field. I decided to add   to each field that was not already populated. The logic in Excel looked like this:

=if(f4=””,” “,f4)

That did the trick but it also uncovered one more bug. When you save the file as a CSV out of Excel, Excel treats the double quote different than mySQL. Excel puts two double quotes together indicating that one should be ignored. PhPmyAdmin has an exception character which defaults to a back slash (\). You cannot use double quote as the exception character because then PhPmyAdmin will ignore all instances of the double quote which is disastrous.

So here’s the work around. Save the files as a CSV in Excel. Next, open the CSV in a text editor such as notepad. Then do a global replace of (“”) with (\”). Then upload the CSV and you are done.

It seems simple now, but it took me a day to figure it all out and I did not find a good reference on the net for this issue so I thought I would add it to my blog.

Another thing. The character set of the file should be changed to Latin1 as it defaults to UTF8. This will avoid a lot of problems when using Latin characters such as é, ç, and ô.

Healthcare in the US and Brazil

Having lived in both Brazil and the US, it truly gives an interesting perspective in the differences between two country’s health systems. Here are some of my observations. I am going to assume that the people reading this article are familiar with the American health care system, so I will just point out the differences.

Test Results. In Brazil, you go to a separate lab to have all of your tests done. Personally, I have had blood work, urine exams, X Rays, and ultra sounds all done in Brazil. The key point is that it is a separate entity. More importantly, they give YOU the test results, and it is up to YOU to get them to the doctor, if you wish. They also put all of your test results on the internet, and you can give your doctor your password to access your records. Over a period of time, you get used to reading your own test results and spotting key indices.

Compare this to the US. Have you ever noticed that when the nurse takes your blood pressure, she writes it down but does not tell you the result? The assumption is that the doctor will interpret the results and inform you if necessary. It’s upside down.

Pharmacy Visits. In Brazil, almost all drugs are available over the counter. The only exception are addictive drugs such as Valium and Oxycontin. It’s happened so many times in the US, that I knew that I had an infection, and I just needed to go to the doctor so he could prescribe some anti biotics. I also have found the pharmacists far more knowledgeable. If you have a certain ailment, you can just go straight to the pharmacy, and the pharmacist will recommend a medication (or give you a shot.)

On top of this, you can get in and out of the pharmacy quickly. Literally in minutes. Compare that the United States. I have no idea what they are doing, but it takes a minimum of 30 minutes to get your medications in the US.

The Doctors. To be honest, I think that the face of medicine in the United States has changed considerably. The doctors are seem so slammed nowadays. They run, and they barely have time to ask the more relevant questions before they have to run off to the next patient. In Brazil, it is much more like the United States when I was younger. Although you still have to wait a long time in the waiting room, the doctors are always patient, and make sure all of your questions are answered. All of my doctors in Brazil have also given me their personal cell phone numbers. To be honest, the Brazil methodology makes me feel more comfortable. I always try to be well prepared when I go to the doctor, but because the American doctor is always so rushed, I worry that we’ll miss something important.

Don’t forget that your health is your own. My wife shops doctors a lot. She wants to get several opinions before determining her course of action.

I have a lot of different thoughts about the root issues, but from a patient’s perspective those are the key differences in health care in the two countries.

Letter from my Grandmother

My grandmother is the most incredible person that I know. As of this writing, she is now 104 years old, and she was close to 90 when she wrote this letter. She was always trying to set me up with some girl. I hope that I am still doing matchmaking when I am 90 years old.

May 6, 1992

Dear Robert,

When I came back from Honolulu, I received a letter from Mrs. Francis Chen. She included a letter from Dr Fan, father of Quang Xi Fan. The father reported that Miss Fan has a change of address. Dr. Fan and Mrs. Francis Chen are both anxious that you get in touch with Miss Fan. The letter must have arrived in the early part of my trip. Today I received another letter from Mrs. Chen. She was anxious to know whether I received the first letter about the change of address and phone. I thought of phoning you tonight, but since you are so busy, I decided to mail you the new telephone number.

I had a wonderful time in Hawaii. Lin-Hua treated me royally. She gave two dinner parties at home and entertained me twice twice in restaurants. Some Yuaching alumnis also gave me a party in a Chinese restaurant. Li-hua also took me out a few times for sight seeing.

It has been quiet inside Village Green but many stores on LaBrea were looted and burned. The worst part was the burning of Security Pacific bank. A day before I left for Hawaii. I took some of the jewelry and bank books and put them in my safe deposit box. I phoned the branch of Security Pacific early this morning and they said that the safe deposit boxes are now transfered to Westchester branch. I have to find a driver and then make an appointment to examine my boxes. Tomorrow, I must go to USC from some business and deposit some money in USC branch so that I can pay some bills. I hope they will have another branch in our neighborhood. ? is the only branch within walking distance.

I miss seeing you and also miss your phone calls. You were much closer to us when you worked for Texas Instruments. Hope you will have time to give me a ring soon. Please take good care of yourself. You are still very precious to me.

Love

Grandma

Huang Chen is going to take me to the cemetery early tomorrow morning. It was a year ago that Grandpa left us.

All’s Well that Ends Well

It was truly one crazy day at hospital for the birth of my first son, Teddy Cheng.

We went into the hospital at 11 pm on 7/2/2007. As soon as we go into the hospital, they assign a doctor to us, and they give us Dr. Forbes. I say “What?” Both Solange and I are surprised because we had been going to a place called the Women’s Wellness Clinic, and had been seeing three different female doctors, with the promise that one of them would be at the hospital during the delivery. The attending nurse goes on to explain that all three of doctors had recently left the state. Wow. Things just keep getting weirder.

We meet with Dr. Forbes, and he seems like an OK guy but there is an air of strangeness since we were expecting someone else. He then breaks Solange’s water and we are in business. About an hour later, a nurse comes in with a big bag of antibiotics. I say “What?” They proceed to explain that Solange had some blood work for strep, and there is no record that the results came back. So they were going to assume that she had it. But it gets better.

It is now 6 am and Solange has been pushing for over 2 hours without result. Note: Doctor Forbes was not present during all of this time just the nurse. Solange is getting tired, as am I. Then the door bolts open and one of the doctors from the Woman’s Wellness Center appears quickly putting on a gown. “I’m here!”, she announces. I get a weird sensation because of all the doctors at the clinic, she was by far the worst.

But stranger yet, the nurses just totally ignore her. They don’t answer the doctor’s questions nor do they respond to her commands. Then the doctor from the clinic disappears. I ask her what was going on. The nurse replies “She is not a doctor.” Now it is totally weird! In the last 4-5 visits to the clinic, it was always the same woman doctor, and now we learn that she was not even a doctor. But my head is reeling.

All this time, Solange is pushing and pushing and she is getting tired. Then it is shift change for the nurse and she leaves. Then the other woman (who we previously thought was a doctor) left. It was just me and Solange pushing. Now all weird thoughts are going through my head. What if the baby is born now? What would I do? I just hung in there and helped her push and jammed her knees to her chest.

It is going on 3 hours, and the next shift nurse comes in and says that it is taking too long. She is thinking ceasarean. Now I’m getting mad. Solange nor I wanted a ceasarean. I demanded to see the real doctor. They told me that they could not find him. I told them to go find him.

After some time, he finally arrived. He said that he had a little vacuum device that would help. It was just a little battery operated thing. Within 10 minutes the baby was out. Tears started streaming uncontrollably down my face. Solange too. After all the weirdness and stupidity, everything turned out fine. God Bless.

Here is the link of the photos Though it sounds cliche, all’s well that ends well.

Lay It Down

I wrote this song while thinking of many of my friends that still work at my ex company Gateway Computer. To be honest, they are struggling right now. My friends in South Dakota are frustrated for change but at the same time, it is hard to change the negative inertia. So rather than be frustrated, they should Lay It Down.

It’s been a while since I had written a full song and this one just popped out in March of this year.

Lay it down

Intro 
A C G A

Verse
Em
I didn't ask to be in the place
Am
And nothing is the same
Em
So many people I don't like
C                    Am                     
But I got no time to complain

So much same old same old
No one's trying anything new
We're not judged on what we say
just on what we do

D
Time's run out for talking
C
This ship's got to turn around
C
It's hard when everyone's watching, 
A            C   G  A
But I got to Lay it down.


Refrain
A        C   G  A
I got to lay it down
C                A
Judgment time is near
A        C   G  A
I got to lay it down
D                E
And put aside my fears

D
I'm not going to leave this place
C
without ever making a sound
C
Now more than ever
A            C   G  A
It's time to lay it down.