开发者

How to export from excel to MySql with dynamic fields inside

I have a problem, I want to export from excel to MySql database table, but the destination table f开发者_StackOverflowield is dynamic. Let's say:

table A for storing field_information (e.g. field_name, field_type)
table B for storing field_answers (e.g. field_info_id, value)

example of excel spreadsheet file (which I convert into cvs format):

name,school,news;
"test","test_school","test_news";

I know I can export from excel to MySql (with static field) using following syntax:

LOAD DATA LOCAL INFILE '\\path' INTO TABLE test FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'

but, what if dynamic field? How could I programmatically know which row of the spreadsheet should go to which database table? Anyone can help?Thanks.


How will you programmatically know which row of the spreadsheet should go to which database table? How about some example rows of the spreadsheet?

Assuming I'm understanding your question correctly, I'd sort the spreadsheet and then do two imports, to the two db tables.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜