CSV To SBPM Converter

This tool will allow you to convert between CSV data and a format that SBPM will (happily) accept.

It will accept data in CSV format, or copied and pasted from Excel and convert it into the SBPM format, with custom variables created for each column.

You can copy and paste data from Excel that looks like this:

screenshot of excel data

And turn it into this:

Manhattan New York/Manhattan(CountyName=New York,StateName=New York,StateAbbr=NY,ZIPCode=10121,AreaCode=212/646/917)
New York New York/New York(CountyName=New York,StateName=New York,StateAbbr=NY,ZIPCode=10121,AreaCode=212/646/917)
Nyc New York/Nyc(CountyName=New York,StateName=New York,StateAbbr=NY,ZIPCode=10121,AreaCode=212/646/917)
Miami Miami-Dade/Miami(CountyName=Miami-Dade,StateName=Florida,StateAbbr=FL,ZIPCode=33155,AreaCode=305/786)
South Miami Miami-Dade/South Miami(CountyName=Miami-Dade,StateName=Florida,StateAbbr=FL,ZIPCode=33155,AreaCode=305/786)

As you can see, the first 2 columns have been turned into the SBPM category and keyword and the rest of the values have become custom variables that you can use within your content.

Notes:

  1. This converter is quite “dumb” and will only convert the data you put into it. It is not (yet) that intelligent.
  2. The CSV data you enter, must have a header row containing unique titles.
  3. The data must be formatted so that the Keyword is in the first column and any other custom variable data is in the next columns.
  4. If there are duplicate header names, you will need to change these either before you paste the data in, or before you click the Submit button.
My data is:
Comma Separated Values (CSV)
Copy and paste from Excel
Semi-colon separated values

I would like:
Keyword(custom1=value,custom2=value)
Category/Keyword(custom1=value,custom2=value)




‘;
}

if(isset($_POST[‘go’]))
{
$get_keywords = explode(“\n”,trim($_POST[‘keywords’]));

//echo “found “.count($get_keywords).” Keywords!”;

if($_POST[‘datais’] == “csv”){$delim = “,”;}
if($_POST[‘datais’] == “semi”){$delim = “;”;}
if($_POST[‘datais’] == “excel”){$delim = “\t”;}

$headers = array_shift($get_keywords);
$headers_data = explode($delim,$headers);

$num = count($headers_data);

foreach($get_keywords as $item)
{
$itemdata = explode($delim,$item);
if($_POST[‘cols’] == “kw”){$out.= $itemdata[0];$x=1;}
if($_POST[‘cols’] == “catkw”){$out.= $itemdata[0].”/”.$itemdata[1];$x=2;}
$out.= “(“;
for ($x = $x; $x <= $num; $x++) { if($headers_data[$x] !=""){ $out.=trim($headers_data[$x]); $out.= "="; $out.=trim($itemdata[$x]); if($x != $num-1){$out.= ",";} } } $out.=")\n"; } echo '

‘.$out.’

‘;
}

?>