Processors Motherboards Chipsets Memory Graphics Cards Storage Cases and Cooling Mobile Systems Displays Shows and Expos
Latest Sponsors

Powered By
Newegg
Tyan Motherboards
Corsair Memory
Western Digital Hard Drives
Red Hat Linux

PC Perspective Forums Sponsor

Go Back   PC Perspective Forums > Software > Linux
User Name
Password
Register FAQ Rules Members List iTrader Search Today's Posts Mark Forums Read

Linux Thinking of giving Linux a try, or got a Linux related question then this is the place to be. Did we mention PCPer runs on Linux!

Reply
 §   #1  
Old 10-31-2009, 11:09 PM
Spankin Partier's Avatar
Spankin Partier
Moderator
Linux/Boinc Moderator
 
Profile
Joined: Oct 2001
Location: Southern Ontario
Age: 36
My System
Status: ( Offline )
Posts: 11,376
Talking AWK saves the day!

I started to play around with my Garmin Nuvi GPS today. Like most GPSs you can add custom Points Of Interest by creating special CSV files. Depending on how you create and name the CSV file you can create automatic warnings if you are speeding, or approaching an intersection that's equipped with a red light camera.

So I started browsing the web and found a site that offers the information to you in CSV format if you subscribe. Well, seeing they still give you all the relevant information, just not in a convenent format, I created this script to do the converting for me:
Code:
#!/bin/sh if [ -e "redlight.csv" ] then rm redlight.csv fi for file in * do if [ -f "$file" ] then awk -F\( '/setLocation\(/ { print $2 }' "$file"|awk -F\) '{ print $1 }'|awk -F\&amp\; '{ print $1 "&" $2 }' |awk -F\' '{ print $1 $2 }' |awk -F\, '{ print $2 ", " $1 ", " $3 >> "redlight.csv" }' fi done
To use this, you simply go to the site linked above, browse to the city you're interested in, and save the page onto your computer. You can repeat this for as many cities as you like, just so long as you save all the data into one directory. Then in a shell, browse to that directory and run the script. In one clean swoop, you have your fancy new CSV file.
__________________
THE SPANKIN' PARTY - Ribbitance is Croaktile

Click the spoiler for team stats:
Spoiler!

Last edited by Spankin Partier : 11-01-2009 at 12:11 AM.
Reply With Quote
 §   #2  
Old 10-31-2009, 11:53 PM
MrBlack's Avatar
MrBlack
Registered User
 
Profile
Joined: Jul 2009
Status: ( Offline )
Posts: 160
Re: AWK saves the day!

cool ...is there a way to get daily speed trap info too?
Reply With Quote
 §   #3  
Old 11-01-2009, 12:02 AM
Spankin Partier's Avatar
Spankin Partier
Moderator
Linux/Boinc Moderator
 
Profile
Joined: Oct 2001
Location: Southern Ontario
Age: 36
My System
Status: ( Offline )
Posts: 11,376
Re: AWK saves the day!

Not sure about that. First of all you'd have to find a website with that information on it, and then alter the above awk command to grab the coordinates off of the page before running Gamin's POI Loader (which works in WINE), then move the POI.GPI onto your device.

So with constantly changing data it probably wouldn't be good. Unless you live in Australia where the police announces where all the speed traps will be before hand. Then you may be able to do this while having your morning coffee and be all set for the day.

I created this script to add in the 378 Canadian and Michigan red light cameras into my GPS. They shouldn't change that often. So if I run this once every couple months I should be up to date.

Last edited by Spankin Partier : 11-01-2009 at 12:06 AM.
Reply With Quote
 §   #4  
Old 11-01-2009, 06:34 PM
Ned Slider's Avatar
Ned Slider
Moderator
Moderator
 
Profile
Joined: Jul 2001
Location: UK
Age: 41
My System
Status: ( Offline )
Posts: 20,202
Re: AWK saves the day!

Nice work Spanky
__________________

~ Want to try Linux - check out the PC Perspective Linux FAQ ~
~ Please take some time to read the Forum Rules ~
~ Feed the spamb0tz, don't mail me here: C3B0tz917328@nirvana.admins.ws ~

Reply With Quote
Reply



Go Back   PC Perspective Forums > Software > Linux

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:01 PM.


Powered by vBulletin
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© PC Perspective 2000 - Present