读一个文件 [英] Reading a file

查看:85
本文介绍了读一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个内置网络服务器的温度传感器,以文本格式提供数据



查询时ip(ttp://192.168.10.220/temp)传感器我得到那种

回复:

探测1 | 82.2 |探测2 | 80.8 |探测3 | -99.9 |探针4 | -99.9

我想将结果导入我的mysql数据库。

最好的方法是什么?

我应该使用fopen()吗?

我试过这个,但我不知道如何获得价值数据......


有没有简单的方法来实现这个目标?

感谢您的帮助。

VooDoo

Hi,
I have a Temperature sensor with internal web server that provide the data
in a text format.
When quering the ip(ttp://192.168.10.220/temp) of the sensor i get that kind
of reply:
Probe 1|82.2|Probe 2|80.8|Probe 3|-99.9|Probe 4|-99.9
I woud like to import the result into my mysql database.
What is the best way to do this?
Should i use a fopen() ?
I have try with this but i don''t know how get just the value data....

Is there a simple way of achieving this?
thanks for your help.
VooDoo

推荐答案

VooDoo写道:
VooDoo wrote:

我有一个带内部网络服务器的温度传感器,以文本格式提供数据。当查询传感器的ip(ttp://192.168.10.220/temp)时,我得到了那种回复:
探测器1 | 82.2 |探测器2 | 80.8 |探测器3 | - 9 9.9 |探针4 | -99.9
我想将结果导入我的mysql数据库。
最好的方法是什么?
我应该使用fopen()吗?我已尝试过这个,但我不知道如何得到价值数据....

有没有一种简单的方法来实现这一目标?
感谢您的帮助。
VooDoo
Hi,
I have a Temperature sensor with internal web server that provide the data
in a text format.
When quering the ip(ttp://192.168.10.220/temp) of the sensor i get that
kind of reply:
Probe 1|82.2|Probe 2|80.8|Probe 3|-99.9|Probe 4|-99.9
I woud like to import the result into my mysql database.
What is the best way to do this?
Should i use a fopen() ?
I have try with this but i don''t know how get just the value data....

Is there a simple way of achieving this?
thanks for your help.
VooDoo




嗨Voodoo,


1)刚打开文件



Hi Voodoo,

1) just fopen the file


handle = fopen(" http://192.168.10.220/temp"," r");


2)读取该行并存储在var。
handle = fopen("http://192.168.10.220/temp", "r");

2) read the line and store it in a var.


myTempLine = fgets(
myTempLine = fgets(


这篇关于读一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆