当您使用with时,文件只会在您的in范围内保持打开状态,当for row in reader:缩进错误时,您的文件将关闭,我在下面测试并得到please select year of study:import csv

LOAD_GEN_DATAFILE = 'C:\\Users\\Dirty-Santa\\Desktop\\blah.csv'

with open(LOAD_GEN_DATAFILE) as csvfile:

reader = csv.DictReader(csvfile)

mydict = {}

for row in reader:

Year=row['Year']

Busnum=row['Busnum']

Area=row['Area']

Power=row['Power']

TLA=row['TLA']

Location=row['Location']

Yearlink=row['Yearlink']

From=row['From']

To=row['To']

Max=row['Max']

Min=row['Min']

year = raw_input("Please Select Year of Study: ")

print("\n")

commands = ["Millwood-Buchanan", "Astoria-East-Corona", "Bronx", "DUNWOODIE-North-Sherman_Creek",

"Vernon", "Greenwood-StatenIsland","West_49th","East_13th","Staten_Island","East_River",

"East_View","DUNWOODIE-SOUTH","Corona-Jamaica","Astoria-East-Corona-Jamaica",

"Astoria-West-Queensbridge-Vernon","Astoria-West-Queensbridge"]

max_columns = 50

for index, commands in enumerate(commands):

stars_amount = max(max_columns - len(commands), 0)

row = "# {} {}({})".format(commands, "." * stars_amount, index + 1)

print(row)

location=raw_input(" \n The list above show the TLA Pockets as well as the ID numbers assigned to them ()\n\n Please enter the ID #: ")

print("\n")

if year in Year and location in Location:

mydict=(Busnum,Area,Power)

print("Here are all the busses at that location for that year and the new LOAD TOTAL: ")

print("\n")

#Busnum, busname,scaled_power read from excel sheet matching year and location

for Busnum,Area,Power in mydict:

Power= float(scaled_power)

Busnum = int(busnum)

print('Bus #: %d\t' % Busnum ,'Area Station: %s\t'% Area,'New Load Total: %d MW\t' % Power)

#API for changing and scaling generation of loads

#psspy.bsys(1,0,[0.0,0.0],0,[],1,[Busnum],0,[],0,[])

#psspy.scal_2(1,0,1,[0,0,0,0,0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0])

#psspy.scal_2(0,1,2,[0,1,0,1,0],[Power,0.0,0,-.0,0.0,-.0,0])

#print("\n")

python中next(reader)_Python错误self.reader.next()相关推荐

  1. Python中的XML解析错误[Et.parse(xml) ‘gbk‘ codec can‘t decode byte]分析与解决

    Python中的XML解析错误[Et.parse(xml) 'gbk' codec can't decode byte]分析与解决 在Python开发中,我们经常会使用XML格式的数据来进行数据传输或 ...

  2. python fieldnames_csvreader.fieldnames在python中未被识别为csv reader对象的属性

    我试图使用CSV模块在 Python中提取CSV文件的标题. CSV文件非常扁平,看起来像: This, That, The Other 1, 2, 3 我正在做以下事情: >读入CSV文件并制 ...

  3. python中gmtime的hour错误_python中gmtime的hour错误_在Python中操作日期和时间之gmtime()方法的使用...

    python中datetime怎么用广告总是在最精彩的时候出现,你总是在小编爱的最深的时候离开. ''''' 日期相关的操作 ''' from datetime import datetime fro ...

  4. python中的变量_Python中的变量

    python中的变量 This lesson deals with variables. Those who already know some programming must be familia ...

  5. python中定义数据结构_Python中的数据结构—简介

    python中定义数据结构 You have multiples algorithms, the steps of which require fetching the smallest value ...

  6. python中mod运算符_Python中的数学运算操作符使用进阶

    Python中对象的行为是由它的类型 (Type) 决定的.所谓类型就是支持某些特定的操作.数字对象在任何编程语言中都是基础元素,支持加.减.乘.除等数学操作. Python的数字对象有整数和浮点数, ...

  7. python中sys用法_python中os和sys模块的区别与常用方法总结

    python 的 python中os和sys模块的区别与常用方法总结 前言 本文主要介绍了关于python中os和sys模块区别与常用方法的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看 ...

  8. Python中的遇到的错误(持续更新)

    1.TypeError: 'dict_keys' object does not support indexing 机器学习实战第三章决策树中遇到的,主要是Python的版本问题,下面这段是Pytho ...

  9. closecmd python_如何在python中禁止控制台/ cmd错误消息

    如何在 python中为chromedriver和pyinstaller exe压缩错误消息? 我注意到当我在pyinstaller中使用chromedriver并运行它时,我得到一个错误消息列表.我 ...

最新文章

  1. Linux字符设备驱动结构
  2. jQuery-点击按钮实现回到顶部的两种方式
  3. 做好数据再利用,让企业数据价值发挥最大
  4. (转)unity web 缓存解决方案
  5. 可重复使用的外科缝合器行业调研报告 - 市场现状分析与发展前景预测
  6. 反射: 反射在中Android运用
  7. java swing图书管理系统 java swing mysql实现的图书管理系统源码(1023)
  8. linux多线程编程书籍推荐:linux大牛之路从这几本书开始
  9. java操作Excel表格使用EasyExcel
  10. 计算机win7开超级性能模式,win7系统设置最高性能的操作方法
  11. shell脚本批量处理ping IP测试
  12. 电机速度rpm转换成轮子的速度
  13. js实现格式化JSON数据方法
  14. 孙陶然:只有不到十分之一的人适合创业
  15. 用无人机撑伞?日本人脑洞真大
  16. android桌面悬浮窗,Android桌面悬浮窗
  17. 什么是七日年化收益率和万分收益?
  18. 常见的股票技术指标到底能赚钱吗?从量化交易的角度告诉你
  19. (附源码)基于JSP的养老院信息管理系统的设计与实现 毕业设计211141
  20. 【管理类联考➕英语二】2020考研高分必看

热门文章

  1. python中字典的常用函数_Python字典dict常用方法函数实例
  2. ansible图形化界面开源_MySQL常见的图形化工具
  3. android studio 修改包名_android逆向笔记之初学者常用adb命令
  4. java convert函数_自己实现 java中 Convert.toDouble(String str)处理函数 | 学步园
  5. 在印度8年的华为工程师,有很多话想说。
  6. 「猜题第一篇」2019年大学生电子设计竞赛
  7. 突发!百度CEO李彦宏被当中泼了一瓶水,肇事者网名:直男上树
  8. ipython使用 python3,2019-04-29 python/ipython设置默认python3
  9. Java线程机制学习
  10. jedis远程连接linux报错