Question

Locked

Need a script (shell/Perl) to insert manipulate a flat file

By mrbungle50 ·
Helo all,
I have a question about designinga script that does two things. My skills in script writing are limited so will need you to be paitent please.
I have a file downloaded to a server (Linux box) that contains set length data in it. for example name, phone_number, address, zip_code, balance
this file is what goes into an application whcih then translates the data and uses it according to certain citeria set in the data in the file.
What I need to acheive is.....
I want to read the zip_code on one row and if the zip_code is (example)9000 I want to add a zone_code of (example)09 to the beginning of the phone_number section.
The file is not delimited by commas etc, but mainly by character spacings.
So if a row in the flat file reads the following:
987412wallabywayPerthWA9077000094730308JohnCitizen
that would be account number,house No,street,suburb/city,state,zip code,leading 3 zeros, phone number, first name, last name.
I want to check if the zip code is 9XXX then remove the last 2 leading zeros and insert the zone code in it's place.
The reason for this to put it in context is in Australia we have telephone area codes that span different states. eg: 08 can be for south australia and the northern territory. But they are on different time zones (only an hour) but if the company calling then customer calls outside of the hours they are liable for massive fines for doing so.
hence why I need to configure by zip code.
If you can find a script that would do this, I would be eternally grateful.
Yours in hope
Craig
MrBungle50

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Custom Programming

by ThumbsUp2 In reply to Need a script (shell/Perl ...

I'm afraid that what you're asking for would require custom programming. There may be some sort of script out there somewhere that might be close to what you want. But, you would need to learn that particular language and customize any script you find for your own application.

So, I'm afraid you'll have to do your own searching and learning along the way. You might start with www.google.com searching for scripts. You'll see there are litterally thousands of web sites with thousands more of pre-written scripts listed and written in nearly any language you can think of.

Point is though, I highly doubt you will find anything that doesn't need to be modified to fit your situation. You'll probably need to write your own.

Good luck!

Collapse -

Download VBSEdit, as it has some good canned scripts builtin

by ManiacMan In reply to Need a script (shell/Perl ...

Of course you'll have to modify the VBScript code a bit to suit your needs, but the bulk of what you're looking for is already in there from the Samples Menu. It really is an awesome VBScript editor, as I myself am not a scripting guru, but I can easily figure things out because the bulk of the code is in there and all I do is change the variables and parameters accordingly.

http://www.programmersheaven.com/download/46325/download.aspx

Collapse -

Data separation

by deity_chooch In reply to Need a script (shell/Perl ...

[ "$ZIP" == "9" ]; then<br/></span>
<span style="padding-left:10px;"># ZIP code has a 9, change it<br/></span>
<span style="padding-left:5px;">else<br/></span>
<span style="padding-left:10px;"># ZIP code has no 9, change differently<br/></span>
<span style="padding-left:5px;">fi<br/></span>
done

Collapse -

I would use the wex (word extractor) chex (char extractor)

by senhu In reply to Need a script (shell/Perl ...

I would use the wex (word extractor-extracts space separated words) chex (char extractor) sin (string inserter) etc. commands in biterscripting as follows

# Get the zip. Assuming it is the 3rd word.
wex "3" $line > $zip
if ($zip=="9000")
# Insert 09 before phone number, which is assumed to be 6th word.
sin "6" "09" $line
endif

I can help you complete the script. Email me. (biterscripting can be downloaded free at http://www.biterscripting.com .)

Hope this helps.

Sen

Back to Networks Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums