读取.csv文件并绘制图形? [英] Read a .csv file and draw graph ?

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

问题描述



我有一个* .csv文件,包含7列和许多行.第一行是标题.
我想逐行阅读csv文件并绘制图形.
我需要第二列和第五列将它们放入像
这样的哈希中 第五列是值和水平轴,第二列是键和垂直轴.
我怎样才能做到这一点 ?

在此先感谢

Hi,

I have a *.csv file, contains 7 columns and many lines. First line is header.
I want to read csv file line by line and draw a graph.
I need second and fifth columns to put them into a hash like
fifth column is values and horizontal axis, second column is keys and vertical axis.
How can i do this ?

Thanks in advance

推荐答案

由于您不是在问基于编码的特定问题,因此我不会提供基于代码的答案,而是提供逻辑您将需要在代码中找出答案.
1)找到,验证并打开文件.
2)逐行读取文件.
2a)处理每条数据线,然后将从那里得出的值放入适当的变量中.
3)关闭文件
4)现在将基于变量的数据应用于图形对象/算法.
5)更新您的显示.
6)就这样...完成了,您可以喝杯冰镇啤酒来做得好.

干杯...
Since you are not asking a specific coding-based question, I''m not going to provide a code-based answer, but rather the logic you will need to figure out in code.
1) Locate, validate and open the file.
2) Read the file line by line.
2a) Process each data line putting the values derived from there into appropriate variables.
3) Close the file
4) Apply the data now based in variables to your graphing object/algorithm.
5) Update your display.
6) That''s it... You''re done and you can go have a nice cold beer for a job well done.

Cheers...


这篇关于读取.csv文件并绘制图形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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