Hi there, so I have a CSV file that has 182 fields. And it would be very time consuming to create a table with 182 columns manually. Does anyone know a MySQL or PHP script that can create MySQL fields from a CSV file? Doesn't even need to read it from a file, I can just copy the chunk of columns directly into the script. No primary needs to be set, nor auto increment. Type should all be LONGTEXT (just to be on the safe side) and collation set to "utf8_general_ci". This is my CSV file, separated by commas: Site,Format,Currency,Title,Condition,SubtitleText,Custom Label,Description,Category 1,Category 2,Store Category,Store Category 2,PicURL,Quantity,LotSize,Duration,Starting Price,Reserve Price,BIN Price,Private Auction,Counter,Buyer pays shipping,Payment Instructions,Specifying Shipping Costs,Insurance Option,Insurance Amount,Sales Tax Amount,Sales Tax State,Apply tax to total,Accept PayPal,PayPal Email Address,Accept MO Cashiers,Accept Personal Check,Accept Visa/Mastercard,Accept AmEx,Accept Discover,IntegratedMerchantCreditCard,Accept Payment Other,Accept Payment Other Online,Accept COD,COD PrePay Delivery,Postal Transfer,Payment See Description,Accept Money Xfer,CCAccepted,CashOnPickupAccepted,MoneyXferAccepted,MoneyXferAcceptedinCheckout,Ship-To Option,Escrow,BuyerPaysFixed,Location - City/State,Location - Country,Title Bar Image,Gallery1.Gallery,Gallery Featured,FeaturedFirstDuration,Gallery URL,PicInDesc,PhotoOneRadio,PhotoOneURL,Gallery2.GalleryPlus,Bold,MotorsGermanySearchable,Border,LE.Highlight,Featured Plus,Home Page Featured,Subtitle in search results,Gift Icon,DepositType,DepositAmount,ShippingRate,ShippingCarrier,ShippingType,ShippingPackage,ShippingIrregular,ShippingWeightUnit,WeightMajor,WeightMinor,MeasurementUnit,CODCost,PackageDimension,ShipFromZipCode,PackagingHandlingCosts,Year,MakeCode,ModelCode,EngineCode,ThemeId,LayoutId,AutoPay,Apply Multi-item Shipping Discount,Attributes,Package Length,Package Width,Package Depth,ShippingServiceOptions,VATPercent,ProductID,ProductReferenceID,UseStockPhotoURLAsGallery,IncludeStockPhotoURL,IncludeProductInfo,UniqueIdentifier,GiftIcon.GiftWrap,GiftIcon.GiftExpressShipping,GiftIcon.GiftShipToRecipient,InternationalShippingServiceOptions,Ship-To Locations,Exclude Ship-To Locations,Exclude Ship-To Type Locations,Zip,BuyerRequirementDetails/LinkedPayPalAccount,PM.PaisaPayAccepted,PaisaPayEscrowEMI,LE.ProPackBundle,BestOfferEnabled,LiveAuctionDetails/LotNumber,LiveAuctionDetails/SellerSalesNumber,LiveAuctionDetails/LowEstimate,LiveAuctionDetails/HighEstimate,LiveAuctionDetails/eBayBatchNumber,LiveAuctionDetails/eBayItemInBatch,LiveAuctionDetails/ScheduleID,LiveAuctionDetails/UserCatalogID,Item.ExportedImages,PhotoDisplayType,TaxTable,LoanCheck,CashInPerson,HoursToDeposit,DaysToFullPayment,UserHostedOptimizePictureWellBitmap,BuyerResponsibleForShipping,GetItFast,DispatchTimeMax,CharityID,CharityName,DonationPercentage,AutoDecline,ListingDetails/MinimumBestOfferPrice,ListingDetails/MinimumBestOfferMessage,LE.ValuePackBundle,LE.ProPackPlusBundle,LE.BasicUpgradePackBundle,LocalOnlyChk,ListingDetails/LocalListingDistance,ContactPrimaryPhone,ContactSecondaryPhone,LocationInfo,ExtendedSellerContactDetails/ClassifiedAdContactByEmailEnabled,ppl_PhoneEnabled,BuyerRequirementDetails/ShipToRegistrationCountry,BuyerRequirementDetails/ZeroFeedbackScore,BuyerRequirementDetails/MinimumFeedbackScore,BuyerRequirementDetails/MaximumUnpaidItemStrikesInfo,BuyerRequirementDetails/MaximumUnpaidItemStrikesInfo/Count,BuyerRequirementDetails/MaximumUnpaidItemStrikesInfo/Period,BuyerRequirementDetails/MaximumItemRequirements/MaximumItemCount,BuyerRequirementDetails/MaximumItemRequirements/MinimumFeedbackScore,BuyerRequirementDetails/VerifiedUserRequirements/VerifiedUser,BuyerRequirementDetails/VerifiedUserRequirements/MinimumFeedbackScore,DisableBuyerRequirements,BuyerRequirementDetails/MaximumBuyerPolicyViolations/Count,BuyerRequirementDetails/MaximumBuyerPolicyViolations/Period,Domestic Insurance Option,Domestic Insurance Amount,InternationalShippingType,InternationalPackagingHandlingCosts,ProStores Name,ProStores Enabled,Domestic Profile Discount,International Profile Discount,Apply Profile Domestic,Apply Profile International,SellerTags,AutoAccept,ListingDetails/BestOfferAutoAcceptPrice,eBayNotes,Paymate,ProPay,Moneybookers,PromoteCBT,ReturnsAccepted,ReturnsWithin,Refund,ShippingCostPaidBy,WarrantyOffered,WarrantyType,WarrantyDuration,ReturnsDetail,WofGMarketplace,WofGCategoryID,WofGDescription,WofGProducerInfo,WofGRegionOfOrigin,WofProduceerPictureURL,WofGQuestionSet,WofGTrustProvider,Fitments Code (markup):
Found a solution: <?php $CSV = "this,is,my,csv,that,contains,lots,of,fields,seperated,by,commas"; $pieces = explode(",", $CSV); echo "CREATE TABLE `test`.`test` (<br />"; for($i=0;$i<count($pieces);$i++) { echo "`".$pieces[$i]."` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , <br />"; } echo ") ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;"; ?> PHP:
I see what you are trying to do; however, having that many columns isnt particularly good database design. You should look into normalizing the table into smaller subsets to avoid replicated data.
It's for eBay's Turbo Lister. I just need to Import CSV files from my wholesaler/drop shipper and convert them to the above format and then export it again. So no need for an actual website. But thanks for the help.