troubleshooting Question

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

Avatar of ROM
ROMFlag for United Kingdom of Great Britain and Northern Ireland asked on
Web DevelopmentPHPJoomla
21 Comments1 Solution26 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


IT is what IT is

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 21 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 21 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004