I trying to use the magicparser to auto detect a file type that users will be uploading. After which I want to use magicparser to then pick the headers of the file and put them into drop downs for the user to map to corresponding fields. I know how to use magicparser to parse the file but could you point me as to how I could pick the headers of the file (xml,csv or txt) using magic parser?
Hi David,
I tried the MagicParser_getFormat() but the returned results are not what i'm looking for. May be i'm doing something wrong.When I use the function by passing this url: MagicParser_getFormat(http://pa......com/data_feed.txt),it prints csv|9|1|0
When I try and xml file I got "xml|ITEMS/ITEM". But what I actually want is to get the header rows in the text file so I can then process that.E.g
Title
Description
url
etc
Am I doing something wrong? Any help is appreciated.
Hello,
You can get the fields from the $record array the first time your myRecordHandler() function is called - they're the keys, and then return TRUE to stop the parse, for example:
function myRecordHandler($record)
{
global $fields;
foreach($record as $key => $value)
{
$fields[] = $key;
}
return TRUE;
}
...and then you will have the field list in the $fields array...
Cheers,
David
Hi,
MagicParser_getFormat() is what you need...!
Cheers,
David
--
MagicParser.com