Dennis Peacock
04-21-2020, 5:56 PM
I'm trying to learn Python on my own and I get the general gist of Python. I've been writting KSH and BASH scripts for a long time "and" I used to write COBOL many years ago. The issue I'm trying to figure out is I have a file that is 274,000 lines long. In "human" terms, the file is broken up into "records" logically speaking. A snippet is like this:
IMAGE blah 0 0 13 blah_1586185200 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586185200 48 1589209200 0 0 2142496 41952 2 2 0 blah_U_FS_1586185200_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
FRAG 1 1 2142496 0 0 0 0 @zzzz app0x 262144 0 0 -1 1028 1;PureDisk;app0x;dp_disk_app0x;PureDiskVolume;0 1589209200 0 65539 0 0 0 6
FRAG 2 1 2142496 0 0 0 0 @zzzz cc0x 262144 0 0 -1 4 1;PureDisk_cc0x_ibmcoslan;dp_cc_cc0x;cloudcata;0 1589209200 0 65539 0 1 0 6 1589209200
IMAGE blah 0 0 13 blah_1586098800 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586098800 44 1589122800 0 0 2121248 42040 2 2 0 blah_U_FS_1586098800_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
FRAG 1 1 2121248 0 0 0 0 @zzzz app0z 262144 0 0 -1 1028 1;PureDisk;app0z;dp_disk_app0z;PureDiskVolume;0 1589122800 0 65539 0 0 0 6 1589122800
FRAG 2 1 2121248 0 0 0 0 @zzzz cc0x 262144 0 0 -1 4 1;PureDisk_cc0z_ibmcoslan;dp_cc_cc0z;cloudcat;0 1589122800 0 65539 0 1 0 6 1589122800 1586100556
IMAGE blah 0 0 13 blah_1586012400 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586012400 54 1589036400 0 0 2108288 42126 2 2 0 blah_U_FS_1586012400_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
I need to break each logical "record" from IMAGE to the end of all the HISTO/FRAG lines...up to the next "IMAGE". In my pee-brain...IMAGE is the start of the record and the next "IMAGE " is the beginning of the next record.
I need to do stuff with info provided inside each "record". I've searched and read a LOT about this online but I guess I'm simply not "getting it". Surely there has to be a simple code way to do this in Python!??!
IMAGE blah 0 0 13 blah_1586185200 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586185200 48 1589209200 0 0 2142496 41952 2 2 0 blah_U_FS_1586185200_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
FRAG 1 1 2142496 0 0 0 0 @zzzz app0x 262144 0 0 -1 1028 1;PureDisk;app0x;dp_disk_app0x;PureDiskVolume;0 1589209200 0 65539 0 0 0 6
FRAG 2 1 2142496 0 0 0 0 @zzzz cc0x 262144 0 0 -1 4 1;PureDisk_cc0x_ibmcoslan;dp_cc_cc0x;cloudcata;0 1589209200 0 65539 0 1 0 6 1589209200
IMAGE blah 0 0 13 blah_1586098800 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586098800 44 1589122800 0 0 2121248 42040 2 2 0 blah_U_FS_1586098800_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
FRAG 1 1 2121248 0 0 0 0 @zzzz app0z 262144 0 0 -1 1028 1;PureDisk;app0z;dp_disk_app0z;PureDiskVolume;0 1589122800 0 65539 0 0 0 6 1589122800
FRAG 2 1 2121248 0 0 0 0 @zzzz cc0x 262144 0 0 -1 4 1;PureDisk_cc0z_ibmcoslan;dp_cc_cc0z;cloudcat;0 1589122800 0 65539 0 1 0 6 1589122800 1586100556
IMAGE blah 0 0 13 blah_1586012400 blah_U_FS 0 *NULL* root daily_onsite 1 3 1586012400 54 1589036400 0 0 2108288 42126 2 2 0 blah_U_FS_1586012400_INCR.f *NULL*
HISTO 0 0 0 0 0 0 0 0 0 0
I need to break each logical "record" from IMAGE to the end of all the HISTO/FRAG lines...up to the next "IMAGE". In my pee-brain...IMAGE is the start of the record and the next "IMAGE " is the beginning of the next record.
I need to do stuff with info provided inside each "record". I've searched and read a LOT about this online but I guess I'm simply not "getting it". Surely there has to be a simple code way to do this in Python!??!