0

我想将文本文件转换为 excel,然后修改 excel 文件中的某些数据,然后将这个新的 excel 文件导入数据库。

例如,excel 文件的内容将是产品及其价格,修改将针对价格。因此数据库和网站上的产品更新将是自动的。我打算使用 OSCommerce

我的问题是:是否有任何用于 OSCommerce 的工具可以配置为我完成这项工作,例如我需要每 8 小时自动执行一次?我需要使用 PHP 从头开始​​编写脚本吗?

4

1 回答 1

0

如果您以简单的 csv(逗号分隔值)格式保存 excel 文件,那么您可以轻松地用逗号分割它并使用 PHP 组织您的数据。

您将使用以下代码从文件中读取数据:

$file_name = "test.csv"; // This needs to be relative to the current location that this script is being executed in 
$fp = fopen($file_name, "r"); // "r" means read, change to "rw" or "w" for read/write and write as needed
$data = fread($fp, filesize($file_name)); // Read the contents of the file into a string
fclose($fp); // Close the file for efficiency
$data = explode(',', $data); // Override data with the array format

这只是一个基本脚本,需要您自己操作才能满足您的需求。祝你好运:)

于 2012-07-14T11:27:53.003 回答