Malicious enjoyment derived from observing someone else’s misfortune
 

Tag Archives: data

Importing MySQL 1.4 Amarok data into Amarok 2.2 Nightly

I was having a bunch of trouble today importing my old MySQL amarok database into the new nightly version of amarok I installed.  The Amarok Wiki had a great section on how to convert a MySQL Amarok collection into an SQLlite one.  This was the key to importing my old 1.4 collection into the new 2.2 nightly version of Amarok.

Reading compressed files with postgres using named pipes

Postgres has the same type of ability MySQL has to read in files, yet much nicer syntax. LOAD DATA INFILE from MySQL is just COPY in postgres. I decided to try having it read from a named pipe today, and it worked out nicely.

Calculating Averages from a CSV with Perl

Code Here’s a quick one-liner using some UNIX utilities and Perl to construct some nice averages from CSV data: for i in `seq 2 20`; do cat crim_rate_2005_by_state.csv | cut -d , -f $i | perl -e ‘$c=$d=0;$e;while(<>){if(/^\d/){$c+=$_;$d+=1}else{s/\s{2,}/ /g;s/”//g;chomp($e=$_);}} print $e, “: “, $c/$d, “\n”‘; done And now, the spaced out version: #!/bin/bash for i in `seq 2 20`; do cat crim_rate_2005_by_state.csv | \ cut -d , -f $i | \ perl -e ‘$c=$d=0; $e; while(<>){ if(/^\d/){ $c+=$_; $d+=1 } [...]