1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Buying need a CSV to MySQL script coded

Discussion in 'Programming' started by tyankee, Mar 25, 2015.

  1. #1
    i need a fairly simple CSV to MySQL script coded that reads the CSV file and then uploads to Wordpress tables. All of the fields are direct upload except for 2 which need special coding:

    the CSV file is composed of automobile listings. One of the fields is called 'images' and needs to be uploaded as file type of 'attachments' for the new 'listing-type' record that was just created.

    the other field that needs to be converted takes the listing title and then converts the 4th word into a 'category' field (there are about 15 categories) and uses that category name for the post field called 'listing'.

    so basically 1 record per CSV file can create anywhere from 1 - 10 records in Wordpress 'posts' table - 1 record for the listing and then multiple records for the images, depending on how many there are. Plus one field from CSV file needs to be analyzed and scraped and then added to the on the wordpress database as a 'category'. this one is confusing to me because it involved the wp_terms tables.
     
    tyankee, Mar 25, 2015 IP
  2. Sir-Mammad

    Sir-Mammad Active Member

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hey
    I am ready to do this
    but can you send me sample of CSV and screenshot of table columns ?
     
    Sir-Mammad, Mar 25, 2015 IP
  3. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 3
    As Buyer:
    100% - 0
    #3
    not sure why you need a sample of the tables. i've attached a sample CSV file in txt format. most of the fields are direct upload from CSV to WP tables. 2 of the fields require special attention.
     

    Attached Files:

    tyankee, Mar 26, 2015 IP
  4. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 3
    As Buyer:
    100% - 0
    #4
    my problem is that i get a CSV file from a customer and most of the fields are 1 to 1 with wp fields, including some custom fields. but there are 2 unique things that have to happen with this CSV file.

    1.. based on the input in an 'images' field, it need to create additional wp_posts records with a listing-type of 'attachment'. if there are 5 image URL's in this field, separated by commas, then 5 additional records must be created. fields on those additional records are pretty basic and can come from the CSV file. So record #1 is for a car listing with 20+ fields filled in. In the images column for that record #1 are 5 images. So record #1` needs to be inserted into wp_posts and then 5 additional records need to be inserted into wp_posts with the parent field filled in with the ID of the car listing record that was just created.

    2. based on the input in the post_title field from the CSV, the 4th word has to be identified. this is the model of the car. the model of the car needs to be looked up in the wp_terms table and then i'm not sure of the process - but the bottom line is to fill in the category/model of this car on the wp tables. here is what the developer of the theme said happens:
    *** In wp_posts there is ID column which identifies each entry ( listings, posts, pages, etc ). In wp_term_relationships object_id column is same as ID from wp_posts, so if you have listing with ID 502, in wp_term_relationships it can be: ID - 502, term_taxonomy_id - 242 which means that listing with ID 502 is assigned to listing category with ID of 242
     
    tyankee, Mar 26, 2015 IP
  5. tyankee

    tyankee Well-Known Member

    Messages:
    1,023
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 3
    As Buyer:
    100% - 0
    #5
    thanks everyone. we found a solution.
     
    tyankee, Mar 29, 2015 IP