[Chicago-talk] Spliting an up undelimited file
Jim Thomason
jim at jimandkoka.com
Sun Sep 11 13:19:25 PDT 2011
On Sun, Sep 11, 2011 at 3:14 PM, <richard at rushlogistics.com> wrote:
> I have a text file that I need to split up so I can put it into a database. However, it isn't exactly delimited. The structure is as follows:
>
> March 1, 2006 Few interruptions. Operations proceed as planed.
> March 2, 2006 Delays due to bad weather and worker absences.
> March 3, 2006 Significant progress. Few absences reported and agreeable weather.
>
> I want to split it up into two scalars: date and event description however since it's not delimited I'm not sure how to go about this. Any suggestions appreciated.
This still looks rigidly structured - "date" "space" "run of text"
while (<>) {
if (/(\w+ \d+, \d{4}) (.+)/) {
my ($date, $memo) = ($1, $2);
#do something interesting with $date and $memo
}
}
or something to that effect. Be more or less paranoid about the format
of the month, date, and year as desired.
-Jim.....
More information about the Chicago-talk
mailing list