Working on a project and coming to dislike Excel due to my being an inept user of it! I recall in Windows XP, Excel 2003, one could sort and filter a spreadsheet by blanks. I was doing some manual work and was hoping to use the “Filter by blank” to save me some time at [...]
Working on a project and coming to dislike Excel due to my being an inept user of it! I recall in Windows XP, Excel 2003, one could sort and filter a spreadsheet by blanks. I was doing some manual work and was hoping to use the “Filter by blank” to save me some time at the end and delete a row if one column were empty. This did not work out; Excel showed me the empty rows but they were not grouped together in way that let me delete them easily. So I wrote a little ruby thing to:
-read the first csv
-create a new csv
-add only rows where both columns contain a string, to the new csv
Obviously this is a very specific problem and I’m sure I was doing something wrong in Excel. Although I came across a lot of premium Excel Add-ons that promised to extend Excel’s “Complex Filter” capability. But it was useful and fun to brush up on some basic Ruby. This script can probably serve as a skeleton for anyone looking to parse one CSV and create a second CSV with set criteria for which data is included. I just used the built in CSV classes and modules, which I hear are replaced in Ruby 1.9 by FasterCSV. But I’m not running 1.9 yet so yeah.
Here’s some test csv data
url,dest
/blah.com/whatever,/blah.com/destination
,2nd element first was empty
filled, also filled
,first was empty
Maybe tonight I will try to replicate in Python and PHP
Content © professional dilettante
Proudly powered by WordPress
Theme designed by Artisan Themes
22 queries.
0.518 seconds.