gpt4 book ai didi

mysql - 如何将 CSV 或制表符分隔文件映射到 MySQL 多表数据库

转载 作者:搜寻专家 更新时间:2023-10-30 22:02:20 24 4
gpt4 key购买 nike

我有一个相当大的 XLS 文件,客户提供了总共 830 个标签/表格。

我用 PHPMyAdmin(显然是 MySQL)设计了一个多表数据库来存放其中的信息,并手动填充了大约 5 个这样的工作表以确保数据适合设计的数据库。

是否有一款软件或某种工具可以帮助我格式化此 XLS 文档并将其映射到数据库中的正确位置?

最佳答案

根据to this thread you can import a csv file exported from excel用 PHP。

引用@noelthefish

as you seem to be using PHP here is a function that is built into PHP

array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure [, string $escape ]]]] )

<?php
$row = 1;
$handle = fopen("test.csv", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: </p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "\n";
}
}
fclose($handle);
?>

this is the very basic of what you need. You would of course put in the database update part within the while loop. Take out the ECHO statements as well unless you are debugging but basically with a little alteration this small piece of code will do what you need. if you need more info check out uk.php.net

关于mysql - 如何将 CSV 或制表符分隔文件映射到 MySQL 多表数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9840723/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com