PHP Developers Network
http://forums.devnetwork.net/

Convert vertical list to database?
http://forums.devnetwork.net/viewtopic.php?f=14&t=128575
Page 1 of 1

Author:  GradyLorenzo [ Sat Mar 19, 2011 12:53 pm ]
Post subject:  Convert vertical list to database?

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

Syntax: [ Download ] [ Hide ]
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...

Author:  greip [ Tue Aug 23, 2011 11:10 am ]
Post subject:  Re: Convert vertical list to database?

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.

Author:  califdon [ Fri Sep 16, 2011 1:18 pm ]
Post subject:  Re: Convert vertical list to database?

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/