I need someone who can transfer my googlebase datafeed to the following CSV form!

Discussion in 'Programming' started by uvip, Jul 7, 2010.

  1. #1
    This is the CSV pattern instruction. Pls PM me if you can help. THX


    The CSV file must have the following structure:
    Category | Manufacturer | Model | Product code| Product title| Product description| Product URL| Product image URL| Product price| Currency

    The field order is mandatory.

    Category - product category on your website
    Manufacturer - the manufacturer
    Model - product model
    Product code - product code, if available
    Product title - product title on your website
    Product description - Product description on your website
    Product URL - URL address of your product from your website
    Product image URL - URL of your product image, if available
    Product price - the price of your product
    Currency - USD


    If some of the fields are missing, you may leave them blank using ||
    Please see the following example for more details:

    Category: Motherboard
    Manufacturer: ASUS
    Title: Asus motherboard
    Description: Asus motherboard is one of the finest available
    Product URL: http://www.yourshop.com/asus-motherboard/
    Product image: http://www.yourshop.com/asus-motherboard/asus.jpg
    Price: 30.00 USD

    The file looks like this:

    Motherboard|ASUS|||Asus motherboard|Asus motherboard is one of the finest available|http://www.yourshop.com/asus-mother...rshop.com/asus-motherboard/asus.jpg|30.00|USD

    If you have 10,000 products, the feed file must have 10,000 lines as above, one product per line.
     
    uvip, Jul 7, 2010 IP
  2. sgcoder

    sgcoder Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What is the format of the data feed that you are using and from where are you uploading it to google base.
    specify the source and conversion would be done as accordingly.
     
    sgcoder, Jul 7, 2010 IP
  3. uvip

    uvip Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I am using CSV files originally. Just want to convert this original CSV to follow the given product info. format. I am uploading it to another database. Thx
     
    uvip, Jul 7, 2010 IP
  4. sgcoder

    sgcoder Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can use fgetcsv to parse the csv file u have into subsequent arrays based on the number of lines u have.....
    <?php
    $row = 1;
    if (($handle = fopen("test.csv", "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            $num = count($data);
            echo "<p> $num fields in line $row: <br /></p>\n";
            $row++;
            for ($c=0; $c < $num; $c++) {
                echo $data[$c] . "<br />\n";
            }
        }
        fclose($handle);
    }
    ?>
    
    PHP:
    once u have got the array write a simple function to convert back the array into the specific csv format which u want....
    
    function array_to_scv($array, $header_row = true, $col_sep = "|", $row_sep = "\n", $qut = '"')
    {
        if (!is_array($array) or !is_array($array[0])) return false;
         
        //Header row.
        if ($header_row)
        {
            foreach ($array[0] as $key => $val)
            {
                //Escaping quotes.
                $key = str_replace($qut, "$qut$qut", $key);
                $output .= "$col_sep$qut$key$qut";
            }
            $output = substr($output, 1)."\n";
        }
        //Data rows.
        foreach ($array as $key => $val)
        {
            $tmp = '';
            foreach ($val as $cell_key => $cell_val)
            {
                //Escaping quotes.
                $cell_val = str_replace($qut, "$qut$qut", $cell_val);
                $tmp .= "$col_sep$qut$cell_val$qut";
            }
            $output .= substr($tmp, 1).$row_sep;
        }
         
        return $output;
    }
    
    PHP:
     
    sgcoder, Jul 7, 2010 IP
  5. uvip

    uvip Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sorry, I do not know code at all. So could you pls help me make this happen? Thx a lot bro!:)
     
    uvip, Jul 8, 2010 IP