需要有关文本处理流程的建议
在我的大部分编程生涯中,我一直是一名研究程序员 (MATLAB),只为我自己编写可以在我自己的计算机上运行的东西。现在,我希望能够让人们提交一个以逗号分隔的文本文件并获得处理后的文本文件作为回报,而无需直接使用我的计算机(只需 1 个 MATLAB 安装)。
我想也许这可以通过 LAN 和一些可以在我的服务器上运行的编程语言脚本在我的网络服务器(XAMPP)上完成。这就是我的想法:
- 让人们创建以逗号分隔的文本文件。
- 让他们访问我在本地主机上创建的网站并通过网页论坛提交。
- 使用 PHP 处理上传的文件(小文件,< 100KB)。这还涉及查找 MySQL 数据库。
- 让人们以某种方式下载处理过的文件。
这是音响系统吗?我所说的“声音”是指,如果您作为专家想要建立这个系统,这会是您会使用的步骤和工具吗?我最近一直在学习 PHP,似乎我可以使用 PHP 来完成此任务,但我不确定这是否是完成该任务的正确工具。整个事情似乎......有点即时,就像你上传文件一样,事情是在 PHP 内存中完成的(根据我读到的),而不是文件存储在我的服务器上并且服务器正在运行使用该文件的脚本(有区别吗?!)。如果你们能插话并给我一些关于如何正确执行此操作的指示(一般想法,而不是要求代码),我将非常感激。
I've been a research programmer (MATLAB) for most of my programming career, writing things for only myself that can be run on my own computer. Now, I'd like to be able to have people submit a comma-delimited text file and get processed text files in return without having to use my computer directly (only 1 MATLAB installment).
I'm thinking perhaps this can be done on my web server (XAMPP) over LAN and some programming language script that can be run on my server. This is what I'm thinking:
- have people create comma-delimited text files.
- have them go to a site I created on my localhost and submit it via a webpage forum.
- have the uploaded file processed in PHP (small files, < 100KB). This involves looking up a MySQL database as well.
- have people download the processed files somehow.
Is this a sound system? By "sound" I mean, if you, the expert, wanted to set up this system, would this be the steps and tools you would use? I've been learning PHP lately, and it seems like I could do this using PHP, but I'm not sure if this is the right tool for the task. The whole thing seems ... a bit on-the-fly, as in you upload the file, and things are done in PHP memory (from what I've read) instead of the file being stored on my server and the server running a script using that file (is there a difference?!). I would be greatly thankful if you guys could chime in and give me some pointers on how to do this properly (general ideas, not asking for codes).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于此类事情来说,PHP 绝对是一个很好的工具。正如 Meterainer 提到的,PHP 为您需要做的大部分事情提供了一个非常简单的解决方案,并且比 Java 或 .NET 简单得多(在我看来)。我也相信它更容易上手。
就指针而言,您需要完成的许多内容以及代码示例都可以在 PHP 手册本身中找到。例如:
文件上传:
http://php.net/manual/en/features.file-upload。 php
CSV 处理:
http://php.net/manual/en/function.fgetcsv.php
或者,metarainer提到的方法
https://www.php.net/manual/en/function.explode。 php
MySQL 数据库:
https://www.php.net/manual/en/book.mysql。 php
https://www.php.net/manual/en/function。 mysql-connect.php
创建新文件:
http://php.net/manual/en/function.fwrite.php
至于这是否是一个音响系统,这完全取决于它的用途。我可能是错的,但听起来您只需要一个简单的应用程序来实现非常特定的用途。如果是这样的话,我会说听起来很好。如果您选择这样做,您以后随时可以对其进行扩展。添加更多的安全措施、更强大的输出等等。不管怎样,至少,你的 PHP 实现对我来说听起来是一个很好的起点。
PHP is most definitely a good tool for something like this. As meteorainer mentioned, PHP offers a pretty simple solution for most of what you need to do, and is much less complicated (in my opinion) than Java or .NET. I also believe it to be much easier to get started with.
As far as pointers go, a lot of what you need to accomplish can be found in the PHP manual itself, along with code samples. For example:
File uploads:
http://php.net/manual/en/features.file-upload.php
CSV Processing:
http://php.net/manual/en/function.fgetcsv.php
or, the method meteorainer mentioned
https://www.php.net/manual/en/function.explode.php
MySQL Databases:
https://www.php.net/manual/en/book.mysql.php
https://www.php.net/manual/en/function.mysql-connect.php
Creating new files:
http://php.net/manual/en/function.fwrite.php
As far as whether or not this is a sound system, that all really depends on what this is going to be used for. I may be wrong, but it sounds like you just need a simple application for a very specific use. If this is the case, I would say it sounds just fine. You can always expand upon it later on if you choose to do so. Adding more security measures, more robust output, things like that. Either way, at the very least, your PHP implementation sounds like pretty good starting point to me.
Ya php 绝对可以满足您的需求。您将使用以下函数:
将 CVS 打开到一个有用的数组中,并对其进行一些存储/数学运算。 PHP 绝对是您的最佳选择。
您还有其他选择,例如 java 和 asp,但在我看来,java 对于您从中获得的功能来说太复杂了,而 asp 需要 .net 许可证,而且与免费的 php 相比,它没有任何授权。
Ya php can definitely do what you are looking for. You'll be using functions like:
To bust open the CVS into a useful array and do some storage/math to that. PHP is definitely your bag.
You have other options, like java and asp, but imo java is far too complicated for what you get out of it, and asp requires a .net license and again, grants nothing over FREE php.