cidaris has asked for the wisdom of the Perl Monks concerning the following question:
I use an application called Easy-IP to keep track of IP utilization. Underneath lies a Firebird database, which I've extracted to CSV. The header line lists all the columns, but I wanted to know the array index for processing. Short of counting commas, I came up with:
My output, abbreviated:
The header line looks like so:head -1 ./current.csv |perl -ane '$i = 0; s/\,/" ".$i++."\n"/eg; print +;'
SUBNET_ID,AUTONOMOUS_NETWORK_ID,PARENT_ID,TREE_PATH,SUBNET,CIDR_MASK,I +P_VERSION,LOW_ADDRESS,HIGH_ADDRESS,BROADCAST_ADDRESS,SHORT_SUBNET,ASS +IGNED_ADDRESSES,CHILD_SUBNET_COUNT,COMMENT,SYSTEM_FLAG1,REPLICATED_FR +OM,CREATED,UPDATED,LOCATION,USAGE,NETWORK_NAME,IP_NETWORK,IP_NETWORK_ +BLOCK,ORGANIZATION,ADMIN_CONTACT,TECH_CONTACT,ORG_NAME,STREET_ADDRESS +,CITY,STATE,POSTAL_CODE,COUNTRY_CODE,PRIMARY_SERVER,SECONDARY_SERVER
My output, abbreviated:
I bet the brains at PM can do better. Suggestions?SUBNET_ID 0 AUTONOMOUS_NETWORK_ID 1 PARENT_ID 2 TREE_PATH 3 SUBNET 4 ...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: enumerate column numbers
by BrowserUk (Patriarch) on Oct 10, 2007 at 16:11 UTC | |
Re: enumerate column numbers
by mwah (Hermit) on Oct 10, 2007 at 16:06 UTC | |
Re: enumerate column numbers
by Fletch (Bishop) on Oct 10, 2007 at 16:43 UTC | |
Re: enumerate column numbers
by cidaris (Friar) on Oct 10, 2007 at 16:32 UTC |
Back to
Seekers of Perl Wisdom