• Technology

    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 ô.

    Leave a Reply


  • Music - Technology

    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.

    Leave a Reply


  • Photos - Technology

    Gateway Badges of Glory

    Solange was cleaning up all my old stuff and she found a bunch of my old Gateway badges. I decided to scan them and finally throw them out. Kind of interesting to see everything in a different perspective.

    Leave a Reply


  • Politics - Technology

    The Oil Age

    Introduction
    Check out this article, The Long Emergency. The article focuses on one basic fact – this year marks when 50% of the world’s oil reserves have been depleted. The article goes on to speculate on what our world would look like without inexepensive and plentiful oil. Have you ever thought about how fundamentally our life styles, our economy, and even the way we think, our intertwined with the basic assumption of free and inexpensive energy? It colors and touches every facet of American existence. So much so that when the world’s oil reserves are depleted, life will change so drastically, that people will reflect back on our lifestyle as a product of the Oil Age.

    Revelations
    One day I was visiting my friends in California, and around 5pm, I had to drive from La Jolla to Carlsbad which is less than 20 miles, but the drive took over an hour to drive. As far as the eye could see in both directions were huge string of car lights from 8 lanes of traffic. The amount of energy being consumed during that hour was staggering. Plus, I had lots of time to think. Here are some of my thoughts.

    Alaska – As we start running low on oil, and the price starts running up, we will have no choice but to drill out the remaining oil. The American economy and lifestyle is addicted to oil, and ultimately we will have to drill in Alaska to feed that addiction. It’s not a question of if but when. Our government should not be fighting the exploration but defining the parameters in which the drilling will occur.

    Time – I can’t exactly pinpoint when the Oil Age began, but let’s say it truly began with the invention of the combustible engine sometime in the late 1800’s. Roughly speaking, the oil age has lasted about 100 years, so far. But now that we are 50% through the world’s oil, the second half of the oil will last us much less than 100 years. The reason is that more and more countries are increasing their demand for oil and trying to join the Americans in the Oil Age. In particular, the monster Chinese economy is accelerating and with it their appetite for oil. My guess is that the Oil Age will end before the year 2050, which means that there is good chance that I will live to see the end of the Oil Age. At least, I will be here to see the impacts of a rapidly depleting oil supply.

    Land – The problem with alternate energy sources is that they require lots of space. In particular, wind turbines must be placed in high altitude locations with lots of wind. And the same for solar panels. Land is still cheap, even in the US, but I suspect the cost of land will skyrocket as it gets ‘developed’ for alternate energy sources as we begin to run out of oil.

    Air Conditioning – One of the biggest energy hogs in our economy is air conditioning our monster buildings. Air conditioning is often attributed toward the migration from the manufacturing northeast to the sun belt. What is going to happen as the cost of keeping ourselves cool and comfortable starts accelerate? Does this radically change the economics of being a Southerner?

    Plans For the Future

    I am sure there are many many more ramifications to our lifestyles. But the most important thing for me is that I want to get ready for this day. I love my lifestyle (and my air conditioning) and I want to protect it. The first thing is that I want to buy some land, lots of it, in a place with ample sun and wind. Then I am going to buy lots and lots of batteries to store all my energy. Afterwards, I am going to build a house on the land. It will be a great house with all the conveniences of home, air conditioning, big screen televisions, a modern kitchen, and of course internet access. But it will also use all of the latest technologies to save energy. Only the best insulation, lights that automatically shut off, and so on. I’ll also have a 100% electric car, but hopefully I will only be a 30 minute drive from a place where I can buy groceries and other necessities.

    As my thinking adjusts, this will be my dream house. I’m going to start building it soon, certainly in the next five years. Best I can tell, things are going to get any better, and I definitely plan to be around for the end of the oil age.

    Leave a Reply


  • Politics - Religion - Technology

    The Case for Stem Cells

    The American Economy Is Driven By Innovation

    When I jump back in time to 1980, the American economy was in trouble. Interest rates were sky high approaching 20%, and inflation was a large concern. Ronald Reagan was elected to office with the promise of trickle down economics, and ‘peace through strength’. Reagan kept his promises and handed out huge tax cuts to the rich while building up the military against the Soviet Cold War threat. The end result was a sky rocketing budget deficit that at the time was unprecedented.

    The picture did not look very pretty to be honest, but there was one thing that saved the day. THE COMPUTER INDUSTRY. Not by any particular governmental or political strategy, America saved itself by becoming the dominant country in the largest global revolution for the next 20 years. Companies such as Intel, Dell and Microsoft all began their meteoric rise in the early to mid 80’s. Although some companies eventually faltered, other leaders included Novell, Lotus, Ashton Tate, IBM and many other American companies.

    But the boom did not just stop there. The 90’s brought us the internet revolution changing the way the world communicates, works, and gets information. Again the world is led by another host of American companies called Cisco, Google, eBay, Yahoo and many many others. I hope I’m not belaboring the point, but American companies had no equal during these times, and I shudder to think what would have happened to the American economy if the PC and Internet revolutions had been led by for example a Japanese and French company. I often think that these companies do not get the credit as the key drivers of the American economy.

    But then it dawns on me. This is just the latest in a string of continuous innovations that have put America as the leader of the economic world and the world’s only superpower. Can anyone deny that our military strength is a function of our economic strength? Going back in time, American companies have led the world time and time again. Telecommunications, airplanes, and automobiles. I’m just spending a little time talking talking about each of these industries, but please take the time to wonder where our economy would be if these industries had not been created and led by American companies. I hope you come to the same conclusion that America’s success is based on our innovation.

    Note that each innovation came at a time when one of our older industries was waning due to foreign competition. For example, the 70’s saw the decline of the once dominant automobile industryto the hands of the Japanese and other foreign competition. I could make an argument that the American’s government r0le should be to promote innovation and not protect old industries, but I won’t.

    The innovation continues today. American companies are the clear world leaders in bio tech creating new drugs the help us live longer, healthier and happier lives. Although it is often the butt of many jokes, the economic impact of Viagra alone on our economy is staggering.

    Now we come to stem cells. It could be the next key innovation and certainly has the potential if successful to drive the world’s economy for a good 20 years. Don’t we want to give American companies every advantage as we endeavor to invent the next world changing technogies? Should the government be doing anything to deter the progress of American innovation?

    Is this what God wants?

    The underlying reason for the entire stem cell controversy are religious. Our president and the Christian right would have us believe that God is morally against stem cell research. And hence our society will suffer somehow from the research. There isn’t a pretty way to say this. It is such hogwash.

    God made us humans, and he made us differently. We alone as a race have the abiltiy to better our existence. A dog’s life is really not much different than it was 2000 years ago, but a human’s life has been enhanced in countless ways. It is innate in our being to learn more and improve our existence, and it is extremely hard to argue that this is anything but God’s will.

    If anyone has been reading the Davinci Code or Angels and Demons by Dan Brown, both books focus on the collision of interests between religion and science. The books argue that there is really no conflict in interest and that each scientific understanding brings a little closer to understanding the creator of all things. When I think about all of the things we know against all of the things we don’t, I am still in awe of the complexity of life and the universe in which we exist. As times goes on, perhaps we will learn more about our Divine Creator through science, but I don’t think there should be anytime when we should slow down our rate of discovery.

    My Prayer

    Dear Lord. Please hear my prayer. I pray that your will be done, and that as humans we all strive to come to know you better on this earth before coming to spend eternity with you. I feel your will in all things, and I believe our thirst and curiosity for knowledge is your way of helping us to know you better.

    Dear Lord. Help America be America by allowing us to innovate. Please help our leaders understand your will better and God Bless America.

    Leave a Reply