Convert vertical list to database?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
GradyLorenzo
Forum Newbie
Posts: 6
Joined: Wed Mar 09, 2011 4:40 pm

Convert vertical list to database?

Post by GradyLorenzo »

Hi all, trying to figure this one out: I have a list that is formatted as follows:

Code: Select all

John Doe
someStreet
someZip
someState

Jane Doe
someStreet
someZip
someState

Jack Doe
someStreet
someZip
someState
How would I convert this into a format that can be imported into PHP MyAdmin? I would type it one at a time, but the 60k+ entries is a bit intimidating for obvious reasons...
greip
Forum Commoner
Posts: 39
Joined: Tue Aug 23, 2011 8:23 am
Location: Oslo, Norway

Re: Convert vertical list to database?

Post by greip »

The easy way to get this large file into a database is to store the file on your web server, then write a small PHP-script which reads the file and inserts the data into the appropriate table.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Convert vertical list to database?

Post by califdon »

Indeed, that's essentially the only way to do it. What you have to be careful of is data format consistency. I would recommend first writing a script that checks the entire file to be sure that each entry is exactly consistent with respect to how many lines of text and empty lines, whether various escape characters are included in the text, etc. If just one entry has more or fewer lines than the rest, for example, all the following data might be misinterpreted. Once you have a consistent source file, the script to read the file and insert rows into the table should be very simple.
Post Reply