从excel导入数字列表 [英] importing a list of numbers from excel

查看:74
本文介绍了从excel导入数字列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python和编程的新手,所以我很抱歉,如果我要说的话没有任何意义。我在excel中有几个不同的数字列表,我想将每个列表保存为某些内容,例如。 MyHighs。截至目前,我刚刚输入了我自己的数字,如下所示...


My_High =(95,96,97,95,91,93,98,97, 99,101,100,100)

Actual_High =(100,99,95,97,91,91,102,99,100,99,99,99)

我在excel中列出了这些数字,我想将该数字列表保存为My_High和Actual_High。但是,我不确定如何导入excel文件,然后保存某些数字列表。我感谢任何有用的提示!!

I am new with python and programming in general so I am sorry if what I am about to say doesn''t make any sense. I have several different lists of numbers in excel and I would like to save each individual list as something, eg. MyHighs. As of right now I have just put in the numbers my self as shown below...

My_High = (95, 96, 97, 95, 91, 93, 98, 97, 99, 101, 100, 100)
Actual_High = (100, 99, 95, 97, 91, 91, 102, 99, 100, 99, 99, 99)

I have those numbers listed in excel and I would like to save that list of numbers as My_High and Actual_High. However, I am not sure how you would import the excel file and then save the list of numbers of something. I appreciate any helpful hints!!

推荐答案

假设您的工作表中有两列。第一列标记为My_High(单元格A-1),第二列标记为第二列Actual_High(单元格B-1)。数字如下所示。最简单的方法是将工作表保存为csv(逗号分隔值)文件,并使用python脚本读取该文件。将数据保存为字典。示例代码:
Let''s say you have two columns in your worksheet. The first column is labeled My_High (cell A-1) and the second Actual_High (cell B-1). The numbers follow in the rows below. The easiest thing to do is save the worksheet as a csv (comma separated value) file and read the file with a python script. Save the data as a dictionary. Example code:
展开 | 选择 | Wrap | 行号


我输入了你给我的代码,作为输出我得到了这个...


99:[]

98:[]

755555543cleaclear:[]


不确定这是什么意思或为什么我没有得到我的数字列表出现。感谢您的所有帮助,我真的很感激。
I put in the code you gave me and as an output I got this...

99: [ ]
98: [ ]
755555543cleaclear: [ ]

Not sure what any of that means or why I wasn''t getting my list of numbers to show up. Thanks for all your help, I really appreciate it.


您的工作表中还有其他数据,并且没有按照我描述的方式进行格式化。 CSV文件应如下所示:我的代码可以工作:


My_High,Actual_High

95,100

96,99

97,95

95,97

91,91

93,91

98,102

97,99

99,100

101,99

100,99

100,99


如果您能告诉我数据的外观,我或许可以提出建议。
You have other data in your worksheet and it is not formatted the way I described. The CSV file should look like this for my code to work:

My_High,Actual_High
95,100
96,99
97,95
95,97
91,91
93,91
98,102
97,99
99,100
101,99
100,99
100,99

If you could show me how your data looks, I might be able to suggest something.


这篇关于从excel导入数字列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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