David,
I have a need to convert some pipe and tab delimited files along with an xml to comma separated and it just occurred to me that MagicParser would do this. Of course PriceTapestry has MagicParser in it, however I wanted to make sure I'm within the license of PriceTapestry / MagicParser if I pull the MagicParser.php file out to use it for converting these files?
Can I get access to the MP forum to ask questions if needed since I own PT? Perhaps I'll just buy a MagicParser license to be sure.
Thanks!
Thanks David,
I've run an xml file from linkshare through magicparser.php and successfully created a .csv file. I've run into a problem though. I'm using the example to convert xml to csv located here http://www.magicparser.com/node/464
the problem is, the xml file has a node for categories, each record could have 1 or 2 or 3 different categories
Below is an example of records with one and two categories within the node.
<link type="TEXT">
−
<categories>
<category id="4">Apparel - Woman’s</category>
<category id="26">Shoes</category>
</categories>
−
<promotiontypes>
<promotiontype id="7">Free Shipping</promotiontype>
</promotiontypes>
<offerdescription>Shop at Time for Me and get Free Shipping!</offerdescription>
<offerstartdate>2009-10-16</offerstartdate>
<offerenddate>ongoing</offerenddate>
−
<clickurl>
deleted affiliate link
</clickurl>
−
<impressionpixel>
deleted affiliate pixel
</impressionpixel>
<advertiserid>25102</advertiserid>
<advertisername>TimeForMeCatalog.com</advertisername>
<network id="1">LinkShare Network</network>
</link>
−
<link type="TEXT">
−
<categories>
<category id="6">Beauty & Fragrance</category>
</categories>
−
<promotiontypes>
<promotiontype id="7">Free Shipping</promotiontype>
</promotiontypes>
−
<offerdescription>
Lancome Online: Free Shipping and Samples year round with your purchase of $85
</offerdescription>
<offerstartdate>2009-10-20</offerstartdate>
<offerenddate>2010-11-21</offerenddate>
−
<clickurl>
deleted affiliate link
</clickurl>
−
<impressionpixel>
deleted affiliate pixel
</impressionpixel>
<advertiserid>25098</advertiserid>
<advertisername>Lancome Canada</advertisername>
<network id="5">LinkShare Canada</network>
</link>
This is causing a problem with the csv file as it creates an additional field in the file and makes it impossible to import without manually removing the extra category fields.
Any advice on how to 'group' the category node into one csv field?
Hi,
As the feed contains variable length records, it would be safer to specify the actual fields you want to export, for example:
function myRecordHandler($record)
{
global $csv;
$line = "";
$line .= str_replace(",","",$record["NAME"]).",";
$line .= str_replace(",","",$record["CLICKURL"]).",";
$line .= str_replace(",","",$record["IMAGEURL"]);
fwrite($csv,$line."\n");
}
If you're not sure what field name values to use (the keys into $record), use this as a temporary myRecordHandler to dump the array:
function myRecordHandler($record)
{
print_r($record);
exit();
}
Hope this helps!
Cheers,
David.
Hi,
That's fine - Price Tapestry includes MagicParser.php so you are licensed to use that script for you own personal / business use - no problem at all!
Use this thread to ask for any specific help, it may be beneficial to other users at some point so ask away...
Cheers,
David.