#! /usr/local/bin/perl5 ######################################################## # Filter for Converting ICPSR SPIRES records into # # sgml (catalog2) # # filter tags (testags2) # # html file descriptions # ######################################################## open(out, ">catalog2"); open(out2, ">tags2"); $tmpdir="/lv4/ssdc/icpsr.guide/records"; opendir(TMP, "$tmpdir"); @tmpfiles=grep(/[0-9]+/,readdir(TMP)); closedir(TMP); foreach $file (@tmpfiles) { %fields=(); $/=";"; open(in, "$tmpdir/$file"); while () { if ($_ =~/INVESTIGATOR = /) { $_ =~s/INVESTIGATOR = //; $_ =~s/\;//; chomp($fields{who}=$_); } if ($_=~/DATE-UPDATED = /) { $_=~s/DATE-UPDATED = //; $_=~s/\;//; chomp($fields{when}=$_); } if ($_=~/TITLE = /) { $_=~s/TITLE = //; $_=~s/\;//; $_=~s/[\r\f\n]//; chomp($fields{title}=$_); } if ($_=~/SUMMARY = /) { $_=~s/SUMMARY = //; $_=~s/\;//; chomp($fields{what}=$_); } if ($_=~/ICPSR.CLASSIF1 = /){ $_=~s/ICPSR.CLASSIF1 = //; $_=~s/\;//; chomp($fields{which}=$_); } } print out < $fields{title} $fields{who} $fields{when} $file $fields{which} $fields{what} EOM print out2 <$file$fields{title} EOM } close(in); close(out); close(out2); $/="\n"; open(in2, "tags2"); open(out3, ">testags2"); while () { $_=~s/[\r\n\f]//; chomp; if ($_ =~/<\/To>/) { print out3 "$_\n"; } else { print out3 "$_"; } } $/=";"; foreach $file (@tmpfiles) { open(jane, ">/web/data/socsci/icpsr.guide/new/$file.html"); print jane "\n"; print jane "\n"; print jane "

\n"; open(bob, "/lv4/ssdc/icpsr.guide/records/$file"); while () { chomp; if ($_ =~/DATA\.FORMAT = /) { $_=~s/DATA\.FORMAT = /Data Format:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/STUDYNO/) { $_=~s/STUDYNO = /Study Number:<\/b> /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/DATE-ADDED/) { $_=~s/DATE-ADDED = /Date of Original:<\/b> /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/DATE-UPDATED/) { $_=~s/DATE-UPDATED = /Date of Update:<\/b> /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/INVESTIGATOR/) { $_=~s/INVESTIGATOR = /Principal Investigator(s):<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/TITLE = /) { $_=~s/\;//g; $_=~s/TITLE = //; print jane "

$_

\n"; } elsif ($_ =~/SUMMARY/) { $_=~s/SUMMARY = /Study Summary:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/COLLECT.NOTE/) { $_=~s/COLLECT.NOTE = /Collection Note:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/SERIES.IN/) { $_=~s/SERIES.INFO = /Series Information:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/TIME.PERIOD/) { $_=~s/TIME.PERIOD = /Time Period:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/SAMPLING/) { $_=~s/SAMPLING = /Sampling Note:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/UNIVERSE/) { $_=~s/UNIVERSE = /Sampling Universe:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/CITATION/) { $_=~s/CITATION = /Study Citation:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/RELATED.PUBS/) { $_=~s/RELATED.PUBS = /Related Publications:<\/b> /; $_=~s/\;//g; print jane "$_

\n"; } elsif ($_ =~/PARTNO/) { $_=~s/PARTNO = /

Study Part:<\/b> /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/PART.NAME/) { $_=~s/PART.NAME = /Name: /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/FILE.STRUCTURE/) { $_=~s/FILE.STRUCTURE = /File Structure: /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/CASE.COUNT/) { $_=~s/CASE.COUNT = /Number of Cases: /; $_=~s/\;//g; print jane "$_
\n"; } elsif ($_ =~/VARIABLE.COUNT/) { $_=~s/VARIABLE.COUNT = /Number of Variables: /; print jane "$_
\n"; $_=~s/\;//g; } elsif ($_ =~/LRECL = /) { $_=~s/\;//g; $_=~s/LRECL = /Record Length:/; print jane "$_
\n"; } elsif ($_ =~/RECORDS.PER.CASE/){ $_=~s/RECORDS.PER.CASE = /Records per Case:/; $_=~s/\;//g; print jane "$_
\n"; } } }