Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Parsing a column of text file - best practices Post 302997804 by SIMMS7400 on Friday 19th of May 2017 04:56:44 PM
Old 05-19-2017
Parsing a column of text file - best practices

HI Folks -

I hope all is well! I have a business process where I manage a text file of substitution variables and their values for a target system. After updating, I run a script to push the changes to the target system.

However, I'm trying to develop a method to be able to automatically advance values without manual intervention. Obviously there may be some exceptions I need to handle in an automated fashion which is fine.

So, the advancement I need to do is week, month and year, based on what subvar it is...

Here is a portion of a sample file :

Code:
CurrentWeek,02/04/17
CurrentWeekq,"02/04/17"
CurrentPeriod,FEB17
CurrenttPeriodq,"FEB17"
1PeriodPrior,JAN17
1PeriodPriorq,"JAN17"
2PeriodPrior,DEC17
2PeriorPriorq,"DEC17"
CurrentPlanYear,FY 2017
CurrentPlanYearq,"FY 2017"

So, i'm trying to understand the best way to advance. The process runs EVERY Saturday, so as you know, the subvars pertaining to the day/week (xx/xx/xx) will always roll forward, but month and year wont until a new month or new year changes...

So this Saturday, CurrentWeek would roll forward to 2/11/17..All others would remain the same.

However on march forth, all week and MONTH subvars will advance. Years wont advance until we advance for Jan 2018.

Just looking for the best way.

Thank you!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Text File Parsing

Hey Guys.I am a newbie on Bash Shell Scripting and Perl.And I have a question about file parsing. I have a log file which contains reports about a communication device.I need to take some of the reports from the log file.Its hard to explain the issue.but shortly I can say that, the reports has a... (2 Replies)
Discussion started by: Djlethal
2 Replies

2. Shell Programming and Scripting

Parsing text from file

Any ideas? 1)loop through text file 2)extract everything between SOL and EOL 3)output files, for example: 123.txt and 124.txt for the file below So far I have: sed -n "/SOL/,/EOL/{p;/EOL/q;}" file Here is an example of my text file. SOL-123.go something goes here something goes... (0 Replies)
Discussion started by: ndnkyd
0 Replies

3. Shell Programming and Scripting

Column wise file parsing.

Shell script for the below operation : File "A" contains : SEQ++1' MOA+9:000,00:ABC' RFF+AIK:000000007' FII+PH+0170++AA' NAD+PL+++XXXXXXXXXXX XXXXXXX XX++XXX XXXX XXXX X.X. XXXXXXXXX+++NL' SEQ++2' MOA+9:389,47:ABC' RFF+AIK:02110300000008' FII+PH+0PSTBNL2A:25:5+BB'... (5 Replies)
Discussion started by: navojit dutta
5 Replies

4. Shell Programming and Scripting

Need help parsing a text file

I have a text file: router1#sh ip blah blah | incl --- Gi2/8 10.60.4.181 --- 10.60.123.175 11 0000 0000 355K Gi2/8 10.60.83.28 --- 224.10.10.26 11 F9FF 3840 154K Gi2/8 10.60.83.198 --- ... (1 Reply)
Discussion started by: streetfighter2
1 Replies

5. UNIX for Dummies Questions & Answers

Replacing a specific column of a text file with another column

I have a text file in the following format: 13412 NA06985 0 0 2 46.6432798439 4 4 4 4 13412 NA06991 NA06993 NA06985 2 48.8478948517 4 4 2 4 13412 NA06993 0 0 1 45.8022601455 4 4 2 4 13401 NA06994 0 0 1 48.780669145 4 4 4 4 13401 NA07000 0 0 2 47.7312017846 2 4 4 4 13402 NA07019... (3 Replies)
Discussion started by: evelibertine
3 Replies

6. UNIX for Dummies Questions & Answers

Replacing a specific column of a text file with another column

Hi, I have a text file in the following format: Code: 13412 NA06985 0 0 2 46.6432798439 4 4 4 4 13412 NA06991 NA06993 NA06985 2 48.8478948517 4 4 2 4 13412 NA06993 0 0 1 45.8022601455 4 4 2 4 13401 NA06994 0 0 1 48.780669145 4 4 4 4 13401 NA07000 0 0 2 47.7312017846 2 4 4 4 ... (2 Replies)
Discussion started by: evelibertine
2 Replies

7. Programming

Parsing a Text file using C++

I was trying to parse the text file, which will looks like this ###XYZABC#### ############ int = 4 char = 1 float = 1 . . ############ like this my text file will contains lots of entries and I need to store these entries in the map eg. map.first = int and map.second = 4 same way I... (5 Replies)
Discussion started by: agupta2
5 Replies

8. Shell Programming and Scripting

Parsing text file

I'm totally stumped with how to handle this huge text file I'm trying to deal with. I really need some help! Here is what is looks like: ab1ba67c331a3d731396322fad8dd71a3b627f89359827697645c806091c40b9 0.2 812a3c3684310045f1cb3157bf5eebc4379804e98c82b56f3944564e7bf5dab5 0.6 0.6... (3 Replies)
Discussion started by: comp8765
3 Replies

9. Shell Programming and Scripting

Parsing text file

Hi Friends, I am back for the second round today - :D My input text file is this way Home friends friendship meter Tools Mirrors Downloads My Data About Us Help My own results BLAT Search Results ACTIONS QUERY SCORE START END QSIZE IDENTITY CHRO STRAND ... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

10. Shell Programming and Scripting

Parsing a fixed column text file in sed

I have a text file with records of the form: A X1 Y1 X2 Y2 X3 Y3 where A is character length 10, Xi is character length 4 and Yi is numeric length 10. I want to parse the line, and output records like: A X1 Y1 A X2 Y2 A X3 Y3 etc Can anyone please give me an idea of how to do this. ... (4 Replies)
Discussion started by: wvdeijk
4 Replies
Datebook(3pm)						User Contributed Perl Documentation					     Datebook(3pm)

NAME
Palm::Datebook - Handler for Palm DateBook and Calendar databases. SYNOPSIS
use Palm::Datebook; DESCRIPTION
The Datebook PDB handler is a helper class for the Palm::PDB package. It parses DateBook and Calendar databases. AppInfo block The AppInfo block begins with standard category support. See Palm::StdAppInfo for details. Sort block $pdb->{sort} This is a scalar, the raw data of the sort block. Records $record = $pdb->{records}[N] $record->{day} $record->{month} $record->{year} The day, month and year of the event. The day and month start at 1 (i.e., for January, "$record->{month}" is set to 1). The year is a four- digit number (for dates in 2001, "$record->{year}" is "2001"). For repeating events, these fields specify the first date at which the event occurs. $record->{start_hour} $record->{start_minute} $record->{end_hour} $record->{end_minute} The start and end times of the event. For untimed events, all of these are 0xff. $record->{when_changed} This is defined and true iff the "when info" for the record has changed. I don't know what this means. $record->{alarm}{advance} $record->{alarm}{unit} If the record has an alarm associated with it, the %{$record->{alarm}} hash exists. The "unit" subfield is an integer: 0 for minutes, 1 for hours, 2 for days. The "advance" subfield specifies how many units before the event the alarm should ring. e.g., if "unit" is 1 and "advance" is 5, then the alarm will sound 5 hours before the event. If "advance" is -1, then there is no alarm associated with this event. New records created via "new_Record" have a 10 minute alarm set by default. "undef $record->{alarm}" to remove this alarm before writing. An alarm icon will still show up in the Datebook if the "alarm" field exists, even with "advance" set to -1. %{$record->{repeat}} This exists iff this is a repeating event. $record->{repeat}{type} An integer which specifies the type of repeat: 0 no repeat. 1 a daily event, one that occurs every day. 2 a weekly event, one that occurs every week on the same day(s). An event may occur on several days every week, e.g., every Monday, Wednesday and Friday. For weekly events, the following fields are defined: @{$record->{repeat}{repeat_days}} This is an array of 7 elements; each element is true iff the event occurs on the corresponding day. Element 0 is Sunday, element 1 is Monday, and so forth. $record->{repeat}{start_of_week} Day the week starts on (0 for Sunday, 1 for Monday). This affects the phase of events that repeat every 2nd (or more) Sunday. 3 a "monthly by day" event, e.g., one that occurs on the second Friday of every month. For "monthly by day" events, the following fields are defined: $record->{repeat}{weeknum} The number of the week on which the event occurs. 0 means the first week of the month, 1 means the second week of the month, and so forth. A value of 5 means that the event occurs on the last week of the month. $record->{repeat}{daynum} An integer, the day of the week on which the event occurs. 0 means Sunday, 1 means Monday, and so forth. 4 a "monthly by date" event, e.g., one that occurs on the 12th of every month. 5 a yearly event, e.g., one that occurs every year on December 25th. $record->{repeat}{frequency} Specifies the frequency of the repeat. For instance, if the event is a daily one, and $record->{repeat}{frequency} is 3, then the event occurs every 3 days. $record->{repeat}{unknown} I don't know what this is. $record->{repeat}{end_day} $record->{repeat}{end_month} $record->{repeat}{end_year} The last day, month and year on which the event occurs. @{$record->{exceptions}} $day = $record->{exceptions}[N][0] $month = $record->{exceptions}[N][1] $year = $record->{exceptions}[N][2] If there are any exceptions to a repeating event, e.g. a weekly meeting that was cancelled one time, then the @{$record->{exceptions}} array is defined. Each element in this array is a reference to an anonymous array with three elements: the day, month, and year of the exception. $record->{description} A text string, the description of the event. $record->{location} A text string, the location (if any) of the event (Calendar database only). $record->{note} A text string, the note (if any) attached to the event. %{$record->{timezone}} This exists iff a time zone has been set for the event. $record->{timezone}{name} The time zone name, e.g., "London" or "San Francisco". $record->{timezone}{country} The country the time zone is in. This is an integer defined in Core/System/PalmLocale.h. $record->{timezone}{offset} This gives the offset from UTC, in minutes, of the time zone. $record->{timezone}{dst_adjustment} This gives the additional offset while daylight savings time is in effect. The offset from UTC is $record->{timezone}{offset} + $record->{timezone}{dst_adjustment} (actually only 0 or 60 are used). $record->{timezone}{custom} Should indicate whether this location was created by the user, though this always seems to be true. $record->{timezone}{flags} Reserved flags. $record->{timezone}{start_hour} $record->{timezone}{start_daynum} $record->{timezone}{start_weeknum} $record->{timezone}{start_month} $record->{timezone}{end_hour} $record->{timezone}{end_daynum} $record->{timezone}{end_weeknum} $record->{timezone}{end_month} These define the period during which daylight savings time is in effect if $record->{timezone}{dst_adjustment} is non-zero. daynum specifies the day of week (0=Sunday, 6=Saturday) and weeknum specifies the week of month (0=1st, 3=4th, 4=last), analagously to the "monthly by day" repeating event. e.g., The "London" time zone has DST starting on the last Sunday of March, which is indicated with start_daynum=0 (Sunday), start_weeknum=4 (last week of the month), and start_month=3 (March). METHODS
new $pdb = new Palm::Datebook; $pdb = new Palm::Datebook({app => 'Calendar'}); Create a new PDB, initialized with the various Palm::Datebook fields and an empty record list. Creates a Datebook PDB by default. Specify the app parameter as 'Calendar' to create a Calendar PDB. new_Record $record = $pdb->new_Record; Creates a new Datebook record, with blank values for all of the fields. "new_Record" does not add the new record to $pdb. For that, you want "$pdb->append_Record". SOURCE CONTROL
The source is in Github: http://github.com/briandfoy/p5-Palm/tree/master AUTHOR
Alessandro Zummo, "<a.zummo@towertech.it>" Currently maintained by brian d foy, "<bdfoy@cpan.org>" SEE ALSO
Palm::PDB(3) Palm::StdAppInfo(3) perl v5.10.1 2010-02-23 Datebook(3pm)
All times are GMT -4. The time now is 02:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy