1
我正在開發一個cron作業,讀取具有json格式的一些配置的配置文件,並且我還有一個csv文件,我必須將該數據插入到mysql tanaro中
I已完成其第一部分,即閱讀配置文件和閱讀csv文件
現在的問題是我必須在csv中搜索配置文件中的mysql列,然後如果在csv中發現匹配列,則必須插入從該列到MySQL表中的值。
我被這個部分卡住了,需要一些幫助來完成這個。
這是示例配置文件,我必須在csv中搜索源代碼,並且必須將其放入csv的detination列。搜索csv列並插入到mysql
"matchingField": [
{
"source": "ProductLongDescription",
"detination": "Description"
},
{
"source": "ExtraTextOne",
"detination": "EventDate"
},
{
"source": "ExtraTextTwo",
"detination": "EventTime"
},
{
"source": "ExtraTextThree",
"detination": "LocationInfo"
},
{
"source": "Zupid",
"detination": "Unique_ID"
},
{
"source": "ProductName",
"detination": "Title"
},
{
"source": "ProductPrice",
"detination": "Price"
},
{
"source": "MerchantProductCategory",
"detination": "Category"
},
{
"source": "ImageMediumURL",
"detination": "ExternalImageUrl"
},
{
"source": "ProductManufacturerBrand",
"detination": "LocationName"
},
{
"source": "ZanoxProductLink",
"detination": "RedirectLink"
},
{
"source": "TermsOfContract",
"detination": "sittingType"
}
]
您可以將整個csv文件存儲到一個數組,然後搜索數組? – joe42
有沒有考慮過使用LESS這樣的東西來做到這一點? http://lesscss.org/ – Machavity
你能給我寄一些幫助代碼嗎? – Shani