westcoaststyle
Programmer
Good afternoon all,
I have a project that just hit my desk that will require me to pull data out of my database and format it based on specific formatting rules with the intention of importing it into a client program using Perl/CGI. An example of this formatting is as follows:
The formatting rules require that each piece of data be placed in a specific column position to be properly read by the importing software. The formatting rules for these three lines are:
There are approximately 30 pages to the list of variables so it will be fairly difficult to automate a great deal of this. My major concern is what the best and most efficient way of pulling the data from the DB and adding the results to the proper Line/Position will be. The data may not always be the same length as the formatting requires and there are also instances where there is no data at all for the fields, but all lengths must be filled either with actual data or blank spaces. I'm getting flashbacks of COBOL with this... Any thoughts?
Thanks for the help.
I have a project that just hit my desk that will require me to pull data out of my database and format it based on specific formatting rules with the intention of importing it into a client program using Perl/CGI. An example of this formatting is as follows:
Code:
EH 20030618123456789
TH T100099-002123456789
TPI 1.0001 N
The formatting rules require that each piece of data be placed in a specific column position to be properly read by the importing software. The formatting rules for these three lines are:
Code:
--LINE1--
Var1: Position=1, Length=3
Var2: Position=4, Length=6
Var3: Position=10, Length=25
Var4: Position=35, Length=11
Var5: Position=46, Length=9
--LINE2--
Var1: Position=1, Length=3
Var2: Position=4, Length=11
Var3: Position=15, Length=9
--LINE3--
Var1: Position=1, Length=3
Var2: Position=4, Length=5
Var3: Position=9, Length=2
Var4: Position=11, Length=30
Var5: Position=41, Length=1
There are approximately 30 pages to the list of variables so it will be fairly difficult to automate a great deal of this. My major concern is what the best and most efficient way of pulling the data from the DB and adding the results to the proper Line/Position will be. The data may not always be the same length as the formatting requires and there are also instances where there is no data at all for the fields, but all lengths must be filled either with actual data or blank spaces. I'm getting flashbacks of COBOL with this... Any thoughts?
Thanks for the help.