1. parsing a 'flexible' text file with SED: i'm in over my head ....
hi all,
i have a massive text-data file that i need to extract key data from,
and format the output.
i initially tried a combination of MS Word & Excel ... massive failure
there!
because of the input file's not-quite-strict format, my best guess is
that a "regular expression" script using a text-parser like SED is the
way to go.
i'm new to SED, and have read through the tutorials i could find, as
well as some of the posts here. one line at a time, i'm pretty much
OK, but processing this file -- well, i'm in over my head.
can anyone out there help with a script that'll do the job, assuming
that SED is even the right tool?
here's the situation:
###############
# INPUT FILE
the data is a simple text file with the following repeating block of
information:
note:
(a) "separator_text" is the same everytime
(b) the NUMBER of data elements under the 2nd variable (varName_2)
in each block varies
-- e.g., 3 elements under the 1st instance varName_2 & 2
elements under the 2nd instance
the
separator_text
(random_text & CRs)
varName_1
var_data_1
(random_text & CRs)
varName_2
var_data_2a
var_data_2b
var_data_2c
(random_text & CRs)
varName_3
var_data_3
(random_text & CRs)
separator_text
(random_text & CRs)
varName_1
var_data_4
(random_text & CRs)
varName_2
var_data_5a
var_data_5b
(random_text & CRs)
varName_3
var_data_6
(random_text & CRs)
separator_text
###############
# OUTPUT FILE
the goal is to extract all blocks of text data from the INPUT FILE and
format the output in a tab-delineated table as follows.
note: i need to create a complete record for EACH
multiple_variable_value ...
e.g., the output for the two blocks above would look like:
varName1 (tab) varName2 (tab) varName3
var_data_1 (tab) var_data_2a (tab) var_data_3
var_data_1 (tab) var_data_2b (tab) var_data_3
var_data_1 (tab) var_data_2c (tab) var_data_3
var_data_4 (tab) var_data_5a (tab) var_data_6
var_data_4 (tab) var_data_5b (tab) var_data_6
This looked really simple at the start ... but I've simply managed to
generate random garbage.
I'd very much appreciate anyone that could suggest a complete script
that would do the job!
Thanks,
Richard
2. testing if running shell script in {t}csh
3. how to parse 'variable=value' format from file
4. Any problem with Internet s/w on Sol 2.4
5. SED: parsing a 'flexible' text file ... in over my head!
6. FAQ: Sun Computer Administration Frequently Asked Questions
7. Linux program can't find ifs lib file -- help
8. Getting Assembly Listing from cc
9. isapnp can't parse pnpdump's config file-- why?
10. Shell Scripts read and parse lines from a file
11. HELP - parsing text file as input to script - HELP
12. Script to parse a Quote file??
13. Shell Script Parsing an XML File on Sun OS 5.5.1