I have a text file that looks something like…
firstname:middle:lastname
firstname:middle:lastname
firstname:lastname
firstname:middle:lastname
firstname:lastname
I would like to be able to eventually use this information in a MySQL database, but since the columns are not correct I am not sure what to do. Is there any way to resolve this?
If the data you have is only the above variations, then you can make the assumptions:
Therefore if using PHP for example you could use
explodeto separate the data on the delimeter such as in this case being:.When looping through each row just assume the last part is the lastname, first part is the firstname and the middle part is the middlename.
You can use
count()to find out how many parts are in the specific row you are reading inside the loop. This should allow you to figure out which one is the last part.