Idris Kadri
Front & Back End Developer & Animator

CSV to SQL Converter

Github

Languages & Tools: Java, SQL

Converts a CSV to a SQL file ready to be imported into wordpress. This program is specifically for wordpress posts as it uses the same database tables.


Sample Code



	

image_title = readCSV.featured_image[i].substring(49, readCSV.featured_image[i].length() - 4); //change post title to featured image

guid = readCSV.featured_image[i].substring(49);

siteMapWriter.append(","" + image_title + ""," + """ + CreateDatabaseImport.website + "/wp-content/uploads/" + post_month + guid + ""," + getPost_Name() + "n");

if(!uploadedImages.contains(image_title)) {
uploadedImages.add(image_title);
uploadedImagesID.add(ID);

//System.out.println(""" + CreateDatabaseImport.website + "/wp-content/uploads/" + post_month + guid + """ + "," );

image_name = image_title;

System.out.println("ImageID " + ID + " : " + image_title); //f + " : " +

writer.append("INSERT INTO `wp_posts` VALUES(");
writer.append(String.valueOf(ID) + ", " ); //count
writer.append(String.valueOf(1) + ", " ); //count
writer.append("'" + post_date + "'" + ", " ); //count
writer.append("'" + post_date + "'" + ", " ); //count
writer.append("''," ); //blank
writer.append("'" + image_title + "'" + ", " ); //count
writer.append("''," ); //blank
writer.append("'" + "inherit" + "'" + ", " );
writer.append("'" + "open" + "'" + ", " ); //count
writer.append("'" + "closed" + "'" + ", " );
writer.append("''," ); //blank
writer.append("'" + image_name + "'" + ", " ); // partially count
writer.append("''," ); //blank
writer.append("''," ); //blank
writer.append("'" + post_date + "'" + ", " ); //count
writer.append("'" + post_date + "'" + ", " ); //count
writer.append("''," ); //blank
writer.append(String.valueOf(ID - 1) + ", " ); //count
writer.append("'" + CreateDatabaseImport.website + "/wp-content/uploads/" + post_month + guid + "'" + ", " );//count
writer.append(String.valueOf(0) + ", " );//count
writer.append("'" + "attachment" + "'" + ", " );//count
writer.append("'" + "image/jpeg" + "'" + ", " );//count
writer.append(String.valueOf(0));//count
writer.append(");");

writer.append('n');

ID++;
}

Back