You are here:  » Million dollar question XML or CSV?


Million dollar question XML or CSV?

Submitted by sbedigital on Wed, 2014-12-17 15:20 in

Hello Dave,

After years of hiding away site management for family reason, I am now back on the scene again. I see your script is changed quite drastically. I am trying to set up few web sites. I would like to utilise the automation functions that PT has. Could please advise me on followings:

I will be using primarily Affiliate Window feeds. They offer XML or CSV feeds. Which format is more reliable in terms of data that is included and formatted to correct specification?

Thanks and have a wonderful Xmas.

Noor

Submitted by support on Wed, 2014-12-17 15:30

Hello Noor,

Where both XML and CSV are available I always use XML out of preference. No particularly good reason to be honest as long as the CSV is well formed, but in general it is a more robust format.

CSV, in actual fact has no formal definition at all. There are no standard ways to incorporate the field separator as part of a field value, and when the solution to that is to "quote" the field value, again there is no standard way to specify the quotation character if it itself appears as part of the field data!

Of course there are generally accepted norms such as escaping or double-quoting and Price Tapestry will handle pretty much any CSV feed you can throw at it; but in general, if you have the option then go with XML.

Have a wonderful Xmas too!

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Wed, 2014-12-17 22:39

I forgot to ask you a related question. Is there any way filter out any product that has a very short title or very long ones? Ideally, i would love to have drop all items that has title of less than 20 characters and those that has more than 80 characters too.

I know its kind of complex filteration, i hope your built-in filter function will be able to do it.

Many thanks for your kind reply.

Noor

Submitted by support on Thu, 2014-12-18 10:00

Hello Noor,

You could add a filter to drop the record based on a minimum / maximum length of the field that the filter is attached to - have a of with the following code for a Drop Record Min Max filter - simply copy and paste into includes/filter.php:

  /*************************************************/
  /* dropRecordMinMax */
  /*************************************************/
  $filter_names["dropRecordMinMax"] = "Drop Record Min Max";
  function filter_dropRecordMinMaxConfigure($filter_data)
  {
    print "Min:<br />";
    print "<input type='text' name='min' value='".widget_safe($filter_data["min"])."' />";
    print "<br />";
    print "Max:<br />";
    print "<input type='text' name='max' value='".widget_safe($filter_data["max"])."' />";
  }
  function filter_dropRecordMinMaxValidate($filter_data)
  {
  }
  function filter_dropRecordMinMaxExec($filter_data,$text)
  {
    global $filter_dropRecordFlag;
    if ($filter_data["min"])
    {
      $filter_dropRecordFlag = (strlen($text) < $filter_data["min"]);
    }
    if (!$filter_dropRecordFlag && $filter_data["max"])
    {
      $filter_dropRecordFlag = (strlen($text) > $filter_data["max"]);
    }
    return $text;
  }

Both fields are optional so you can drop based on just a minimum, just a maximum, or both.

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Thu, 2014-12-18 19:37

Hi dave,

I have added the code my includes/filtre.php everything seems to be fine but it when i register the feed, and then import it, no records are dropped from the feed. I had tried 26 min and 75 max combination of min, max and both scenarios.

I also noticed that there are no codes inserted withing the curley braces of function filter_dropRecordMinMaxValidate($filter_data) function.... is that intentional?

Thanks for time.

Noor

Submitted by support on Thu, 2014-12-18 19:54

I'm sorry Noor, the auto-complete functionality in the text editor I was using to craft the solution got carried away with itself and converted each instance of $filter_dropRecordFlag into $filter_dropRecordMinMaxFlag! New filter code corrected above.

Cheers,
David.
--
PriceTapestry.com