CSV Splitter

A nifty command line tool to split up a csv file, based on column values.
http://csvfix.byethost5.com/csvfix.htm
It has many features, but I used it for it’s very efficent file splitting function.

The file_split command splits a CSV input stream into a number of files based on the values of specified fields in the CSV input stream. All the CSV records with the same values for those fields will be placed in the same file. By default, the created files are numbered, but you can also generate files based on the contents of the fields used to perform the split. Unlike most other CSVfix commands, this command does not write anything to standard output, or to any file specified by the -o flag.

Note that any existing files will be overwritten by this command, without warning. Use the -fd flag to locate the output files, and the -fp and -fx flags to name them.

-f fields (Required) : Comma-separated list of filed indexes on which to base the split.
-fd dir : Specifies the directory in which to place the results of the split. Defaults to the current directory.
-fp prefix : Specifies the prefix to use when constructing file names. Default is file_
-fx ext : Specifies the extension to use when constructing file names. The default is csv
-ufn : Use the contents of the field(s) specified by the -f flag to generate file names. No check is made that the fields contain valid filename components, and the command will fail if they do not.

The following example splits the cities.csv file based on the second field, which contains the country code.

csvfix file_split -f 2 data/cities.csv

This produces the following files, each of which contains the cities for a particular country:

file_0001.csv
file_0002.csv
file_0003.csv
file_0004.csv
file_0005.csv
file_0006.csv

With the same data, the following example:

csvfix file_split -f 2 -ufn data/cities.csv

uses the country code values to generate the file names, producing:

file_DE.csv
file_FR.csv
file_GB.csv
file_GR.csv
file_IT.csv
file_NL.csv

Here, file_DE.csv will contain German cities, file_FR.csv French cities, and so on.

Advertisements

Use angular.js with WordPress

AngularJS And WordPress

1. Download zip file.
[wpfilebase tag=file id=1 /]
2. Install and activate the plugin.
3. Set wp-angularjs-include to true in Custom Fields on post edit page.

Sample test code:

<div>
  Name:
  
  <hr>
  <b>Hello <span style="color:#ff6600;">{{yourName}}</span>!</b>
<div />

Sample test code output (type anything into the input field to see “Hello …” string update:

Name:

Hello {{yourName}}!

Howto: Upgrade to latest php version (Ubuntu)

Upgrading php to php 5.5 (currently stable version)

  • add-apt-repository ppa:ondrej/php5
  • apt-get install python-software-properties
  • apt-get update
  • apt-get upgrade
  • apt-get dist-upgrade

You do get option to replace your apache2.conf file, but I would select to keep your old version.  In this instance, upon starting Apache, you MAY get error relating to httpd.conf and Lockfile statements. Just comment both of them out of apache.conf, and Apache will start fine.

“Anonymous”

Anonymous

I have had a few years of frustration at self-proclaimed “web saviours” amounting to little more than scattergun ddos attacks, ftp and database compromises. All, I should say, as easy to protect yourself against. For a start don’t use ftp! Switch that service off, and use ssh or a secure ftp protocol to deal with file management. I have had a few more experiences this year dealing with fallout from hacker attacks, along with some communication to some groups and individuals.

I have been a little hard on youth, as it is easy to lose focus by getting caught up in a moment. Sometimes I believe hackers confuse the web itself with their targets. Attacking random websites, just because you found back-door access into server or database, seems a little churlish and not in the least bit revolutionary. “Highlighting security flaws” is a pretty weak motivation, as who does it really benefit. The hoster? They nail that particular hole shut and go about their business. Meanwhile the hosters’ customers are the ones who sustain the actual damage.

Anonymous

One of the more publicly known of the more focused hackers is the “The Jester” – he calls himself a (US) Patriot hacker. Maybe not best of starts, but his targets are deliberate – mainly Islamist extremist websites, but occasionally sidesteps onto other projects such as the turgid Westoboro Baptist Church and the tasteless twitter trolling site that appeared quickly in the wake of the Newtown school shootings.

There is an arrogance in the hacker world – as with anything with tech, you get the stars and a million imitation drones. It is easy enough to create a presence on the web and declare yourself and Anonymous hacker. Take credit for other attacks, blame embarrassing boo-boos on other. There is a childish level of “blame culture”, but now the “stars” are easier to spot as they carry an agenda is that understandable and to varying degree, morally sound.

What currently interests me how few seem to challenge hackers online. For all the umprompted outpourings of opinions, no-one seems to challenge something so prevalent and so potentially damaging for individuals. Are you sure you don’t have an opinion? Usually with a little digging you can find responsible party for a website attack. Though there are truly anonymous hackers out there, most will publicise their action in some way. Even if it is just boasting in a readme file! My point is if you don’t voice up when you think something is wrong, how will they ever know. “Script kiddies” are getting to be a bit of a curse, rather than any help.