Convert .csv files to js or JSON via Python.

I used the JavaScript data visualization library D3.js and have distributed my work to customers who view them via web browsers. However, there is this annoying problem of not being able to reference local files because web browsers by default disable this for security measures. My work-around has been to use an MS Excel VBA macro to convert .csv to a .js file with a big JSON variable that I can then refer to with something like script src=’data.js’. Well, it’s time to modernize, and do the same with python. In summary:

  1. read data.csv
  2. create a string that is “data = {my JSON objects}”
  3. write to a file data.js

My .csv looks like this:

ScreenHunter_01 Oct. 28 20.14

And here is the code. Unfortunately, WordPress is not code-text friendly.

ScreenHunter_05 Oct. 28 20.39

Output looks like this:

var data = [{‘Name’:’Joe’,’Age’:’12’,’Debt’:’23’},{‘Name’:’Fred’,’Age’:’53’,’Debt’:’2′},{‘Name’:’Chris’,’Age’:’2′,’Debt’:’1′},{‘Name’:’Jeffrey’,’Age’:’67’,’Debt’:’2′},{‘Name’:’Chris’,’Age’:’2′,’Debt’:’4′}]

Advertisements
Posted in Code, portfolio | Leave a comment

Jigar Shah – EPA Withdrawal from Clean Power Plan: All Bluster

Regulation is not killing old coal. Better technology and better deals are. Are economic prosperity and cleaner energy mutually exclusive options or symbiotically dependent forces?

https://www.linkedin.com/pulse/epa-withdrawal-from-clean-power-plan-all-bluster-jigar-shah/?trackingId=%2BXvuB1cHfMfU%2Bpk0IEQF%2BA%3D%3D

 

Posted in Science | Leave a comment

MobileEye on Setting the Rules For Autonomous Driving

My main fear with autonomous driving is that for it to work, all cars need to be autonomous. Assuming the automation works well, the biggest risk would be the most unpredictable: human drivers. But what if automated systems were proactive and prevented the automated car from being in a scenario where human drivers could interfere? Intel’s MobileEye is exploring this. White paper here.

 

Posted in Recommendations | Leave a comment

AI Needs AI-specific Silicon

As the artificial intelligence revolution is underway, it is no longer sufficient to run AI software on chips built for conventional computing. companies like Google and Microsoft are being forced to make their own chips. Now is the time for Intel to step up to the occasion.

https://www.wired.com/story/the-rise-of-ai-is-forcing-google-and-microsoft-to-become-chipmakers/

 

Posted in Science | Leave a comment

Salt Batteries: Cheap but Abundant

Li-ion batteries are the most widely used batteries today, but they are expensive. Is it possible to make sodium batteries at scale? Some of my favorite PI’s at Stanford collaborated on tackling this question.

Abstract

Full Text

What companies could be potentially interested in capitalizing on this technology? Here’s a great dynamic list by CleanTechnica.

 

 

Posted in Recommendations | Leave a comment

Coexistence of Flexibility and Focus for Intentional Work

Is it possible to have laser focus while having flexibility to multi-task? Yes, as described by Facebook VP of Product Fidji Simo. Key is to identify high-level goals, quantify how much time and when for each task, and then focus on that one thing at the moment.

http://firstround.com/review/how-facebooks-vp-of-product-finds-focus-and-creates-conditions-for-intentional-work/

 

 

Posted in Recommendations | Leave a comment

What to do with your life in 3 circles

“What to do with my life?”

This is a very fundamental and difficult question that most if not all people struggle with. While difficult, the answer can be simplified by a Venn Diagram illustrated by Suzy Welch. Check it out:

https://www.cnbc.com/2017/09/25/this-simple-diagram-will-help-you-figure-out-what-to-do-with-your-life.html

The answer is really about finding the golden threads that connect your skills and interests with what the economy needs. After all, I believe that the economy exists to incentivize people to utilize their capabilities for the common good.

I would like to add that skills are not just what you are “born with” or “naturally good at”. I would say that your core skills are the ones that you are willing to endure developing for the long term with grit even if you appear to not be good at them compared to your peers.

 

Posted in Recommendations | Leave a comment