循环不会遍历所有csv文件read,python2,pycharm

时间:2016-05-03 16:18:44

标签: python-2.7 loops csv

这是我的代码:

import csv
inp1 = raw_input('Enter your Hijjri year:')
intinp1 = int(inp1)
majmouaopen = open('Majmoua.csv')
majmouaread = csv.reader(majmouaopen)
majmouaread.next()
mabsoutaopen = open('Mabsouta.csv')
mabsoutaread = csv.reader(mabsoutaopen)
mabsoutaread.next()
hijrimiladimonthsopened = open('MiladiHijrimonths.csv')
hijrimiladimonthsread = csv.reader(hijrimiladimonthsopened)
yearslist = []     
years = []
yearssection = []
monthssection = []
minutessection = []
def miladifromhijri(intinp1):#, inp2, intinp3):
    fulyear = intinp1 - 1
    n = 0
    for row in majmouaread:
        print row
        introw = int(row[0])
        if introw <= fulyear:
            n += 1
            years.append(introw)
            continue
        if n == len(years):
            near = years[::-1][0]
            nearlessyear = near
        break
    for row in majmouaread:
        print row

我的问题是最后一个循环,它不会打印所有的majmouaread文件。对于第一个循环,它是相同的,它会打印所有csv文件行。 是什么导致了这个问题,是代码中的东西吗?或者csv文件中发生了什么事情?第一次循环看起来很好吗?

0 个答案:

没有答案