troubleshooting Question

Best way to import file into PHP.. Has its own tags NOT CSV.

Avatar of Romolo
RomoloFlag for United Kingdom of Great Britain and Northern Ireland asked on
Web DevelopmentPHPJoomla
21 Comments1 Solution24 ViewsLast Modified:
Hi Everyone,

I have part of a project where I need to import an RTF file that has custom tags that I need to build a set of data. This will be based within a Joomla Framework if that changes any suggestions.

So the task is:

a) Import file via PHP.
b) Need to process either line by line or post import and cut the file into database records. E.g. Line 1-4 is a piece of information. Tagged as such. And needs to split into 5 fields within a table.
c) Allow me to parametise this so I can maintain it as this format changes as variations happen from one year to the next.

I am right at the start so would like some guidance as this is NOT a CSV file.

My first challenge is getting the file imported. Hows and to where. I would like a copy of the the PIECE OF INFORMATION in its entirety as well as the broken up part into fields.

Then it is to either process as it imports or post process if I import into staging table and blob field or something. It is that working through the file and then moving the data into table records etc...

Bit of info.

File looks like this:

{Info/sec/newinfostart In the new office}
{Info/sec/keypeople Dan,Mary}
{Info/sec/focuspeople John, Leanne}
{Info/sec/tasks task1}
{Info/sec/tasks task2}
{Info/sec/tasks task3}  
{Info/sec/endinfo End of Information card}
{Info/sec/newinfostart At the swimming pool}
{Info/sec/keypeople Tim,Mary}
{Info/sec/tasks task1}
{Info/sec/endinfo End of Information card}
{Info/sec/newinfostart Evening time at the gym}
{Info/sec/keypeople Joe, Laurie}
{Info/sec/focuspeople Gerald}
{Info/sec/tasks task1}
{Info/sec/tasks task2}
{Info/sec/endinfo End of Information card}

So this would be split into using the first Info Card as an example:

ID, Location,  Main People, Secondary People, All Tasks, Original Info Card
1, In the Office, Dan - Mary, John - Leanne, Task1 - Task2 - Task3, ALL INFO WITHOUT TAGS
2. At the swimming pool, Tim - Mary, , Task1, ALL INFO WITHOUT TAGS

And so on.

There is a lot more information that I am placing here to give a very general idea of what I am trying to do. It is not csv based. It does have identifying tags for the piece of info and line start and end with curly brackets.

Unsure about start approach and do not want to get lost in a see of Google articles.. saying that .. most appear to revolve around structed delimited data on one line.

I cannot change the format and contents of the file... This is how I receive it. Bit like reading machine code for cues.

Please advise and help

Many thanks in advance


Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 21 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros