pie2re has asked for the wisdom of the Perl Monks concerning the following question:
I'm currently trying to load some data coming from a text file into a database.
Here is a sample of data as it can be found in the file
27509. The Sun's declination is: A) the Sun's position relative to the plane of the Equator. B) the distance between the Sun and the horizon. C) the angular distance between the Sun and the celestial North Pole. D) the Sun's position relative to the ecliptic.
The problem is the following:
I would need to be able to handle the question id (the number on the first line), the question and each answer (a,b,c,d). As you can see in the sample above, the data is not very well formatted and sometimes the answer is spread on several lines. The file contains up to 2500 questions ans answers.
So, basically my question is:
How could I parse the file to isolate every question with its answers even if one answer is spread on several lines?
Thanks a million for your help.
P.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple choice from text file to SQL
by kennethk (Abbot) on Mar 03, 2009 at 15:32 UTC | |
by pie2re (Initiate) on Mar 03, 2009 at 20:43 UTC | |
by kennethk (Abbot) on Mar 03, 2009 at 21:24 UTC | |
|
Re: Multiple Line Data from text file to SQL
by clueless newbie (Curate) on Mar 03, 2009 at 21:08 UTC |