Split CSV File Into Multiple Files Using Python

A few days ago I wrote about a small Python class which I created to merge multiple CSV files into one large file. I had tried to make it extensible a little bit. Ironically only a few days later I found myself in a situation where I needed to do the exact opposite task and split a large csv file into smaller chunks. I’m going to walk you through some of the changes thinking I went through updating the class. You can find the original article and class posted here

Append CSV Files Together With Python (Skipping Headers)

Authors Note: This code has been updated and improved upon. I won’t remove this post, but I highly suggest you use the code from the improved code in the post found here.

Last night I had a project where the client needed 30 .csv files compiled into a single sheet. I figured that I could concatenate them together using Python real quick. Python makes tasks like this fairly trivial, but I like to experiment a bit so rather than just write a loop appending each file I wrote a class to do it with some methods. It’s reusable for anyone who has a similar task. I had wanted to add a utility which would compare the headers of 1 file with the headers of the previous file but I was on the clock so I’ll save that bit for another day.

Python has a csv module but I don’t use it in this class yet. The Python csv module is really just a utility in itself to make working with CSV text files easier. Since there is no difference between a regular text file and a csv file and I know the format of the files being fed to the class I simply used Pythons open method to grab a handle to my files. I did import the csv python module though to remind me to use it when I extend this in the future.

Live Templates - Code Quicker Using JetBrains IDEs

When using an IDE such as WebStorm, PHPStorm or PyCharm we can save a lot of time by using Live Templates. They allow us to type an abbreviation such as if then press TAB and the IDE will generate an entire “If Statement” in the code. They are called “live” because they’re more than just snippets of text which are dropped into a file. The live template knows which files use which version of a snippet and will bring our cursor through each part of the template that requires customization, we can place variables in live templates as we build them later when the live template is activated it will help us customize each variable spot in the snippet. It saves much time…

WP Plugin Which Creates Posts Everytime Lines Are Added to Google Spreadsheet

One of the things which I’ve developed recently and is in active use on a couple websites at the moment is a WordPress plugin which will make posts out of lines in a spreadsheet stored on Google Drive. Doesn’t sound too impressive? What if I told you that the plugin not only handles multiple sheets, it allows the user to create headings at the top of their spreadsheet which can be used as variables in a template for each post, each sheet and template can be updated at different intervals and the plugin will even remotely fetch featured images automatically if told to use one of the fields as an image. The field to store as featured image must be a url and the plugin will download and store the image as an attachment to the new post.

My MVC Summer/Fall - a Corporate Webapp and Cordova Mobile

I have not made an entry into the dev diary in almost 9 months.. and I’m not going to try to sum up all that time in one post. I’d just like to speak on the past few months of work, what I’ve accomplished over the summer and where I see myself going forward in the web development industry. If memory serves me, in June of this past year (2015) Google announced the Polymer 1.0 release and informed the world that Polymer was production site ready. This was awesome news for the web dev community except maybe certain folks who had jumped to production with Polymer 0.5, but Google put out a migration guide at the same time as the announcement or immediately after. In any light, Polymer 1.0 is hip, fast, and brings web components into the now. Plus Polymer developers gain so much value from the paper/iron/gold/platinum elements released by Google, I won’t get into that but lets just say I was and still am pretty dern excited!

Matrix Addition (JavaScript)

Matrix Addition challenge instructions

Write a function that accepts two square matrices (nxn two dimensional arrays), and return the sum of the two. Both matrices being passed into the function will be of size nxn (square), containing only integers.

How to sum two matrices:
Take each cell [n][m] from the first matrix, and add it with the [n][m] cell from the second matrix. This will be cell [n][m] in the solution matrix.

Sync WooCommerce Product Variation Menus

I was doing work on a WordPress store where the designer had arranged WooCommerce variation single products using Visual Composer. Visual composers are very popular these days and offer a GUI to easily place modular content inside grid layout containers. This affords designers great control over content and widget placement but not much control when it comes to inter-behavioral module communication1. The client had a site which required additional behavior coupled between variation <select> <option>s of a few different WooCommerce products which had already been placed in different areas of a page using Visual Composer. This was an interesting request because in the visual composer WooCommerce products become “single products” which under normal conditions are isolated with their own “Add to Cart” buttons and each is placed into the cart by a separate user action and without respect to any other products in the layout2. When a user selected a variation <option> from the pages top product the client wished to synchronize the drop down <select> <option>s of the products lower on the page to mirror the value of the selected <option>. This behavior is one way so the user may explicitly change the value of variations on lower products without effecting previous selections on other products.

Thinking Forward. Just for a Moment

Technology moves fast blah blah blah. But it’s true, in the short time I’ve been alive we’ve seen more technological advances then in all the years before I was born. I suspect that we’ll see just as many more in the next 8 as we’ve had in the past 30. I’m not one of those people who believes the human creative mind has a plateau, and if anything can be gleaned from the exponential rate of advancement this age of computers has brought us, it might be that if there is may be a plateau on the growth of the human mind, but there is no plateau on the growth of humankind. We move forward. Regardless of how much it is we actually understand about the direction we move [forward] into…

The Most Complicated Responsive Conversion

So I need to start writing down my thoughts, lest they escape me. I read it online, so it must be true. Also, I’m a very avid reader of technical documents, so I know it’s true. Information that is consumed but not properly digested is quickly forgotten.

There are a few ways to make sure that knowledge isn’t so fleeting. One of the best is by recalling it. We recall things when we use them, remember them at a later date, teach them. A good experiment if you don’t believe me, read for 20-30 minutes, something heavy, but not so heavy that you don’t feel as if you understand it. After the 20-30 minutes are up, sit back and think about everything you learned. Talk about the ideas expressed in the text inside your own head… it should be easier to do then it actually is. I’m sure you will succeed, but imagine you had waited 24 hours to sit back and think about the text, what about a week?

Node Ones Been Home

Dev Diary,

So I haven’t been posting much lately. I’ve actually been doing a lot of Node.js in my spare time. Along with updating my tablet and smart phone to the Samsung S4 and S5 respectively. There is a lot that I would like to share in tutorials. I’m actually about 90% through writing a tutorial on creating a PHP Captcha as well as a little bit of writing that I have done regarding jQuery.data(). Fun stuff all around. I would also like to get some writings up about jQuery Deferred and some basic Nodejs code. I’m relatively new to node myself, so anything I write will be beginner level. I try not to write about things that I do not know well, as it can cause trouble in someone else’s learning process. I’ve been there before, where I’ve spent time reading something that seemed to be legit, only to find out it’s wildly incorrect. It’s disappointing and a waste of time. At any rate, I just wanted to check in.

I did recently post a jQuery plugin at //onethingsimple.com/lite-the-way, it allows you to easily add classes to items that fall outside of a fixed margin within a reading area. Just go check out the demo page there and you will see everything. It’s a very cool little plugin and very easy to use as well, just $('p').litetheway().