通过pandas python写入csv文件中的连续行

时间:2018-06-06 07:07:20

标签: python pandas

如何使用pandas.Dataframe继续写入连续的行?我有以下连续调用的函数,并将给定的值写入.csv文件,但值被覆盖在同一行。有没有办法可以指定它写入连续的行?

def csv_writer(filename, OutputFolder):

    f = open(OutputFolder + '\Output_' + filename +'_LOG.txt')
    s = f.read()
    m = re.search("GHz\s+\=(.*)dB",s)
    if m:
        Lossval = float(m.group(1))
        print("Loss Value for filename " + filename + "is :", Lossval)
        params['Lossval'] = Lossval

    n = re.search("Impedance\s+\=(.*)ohms",s)
    if n:
        Zc = float(n.group(1))
        print("Impedance Value for filename " + filename + "is :", Zc)
        params['Zc'] = Zc

    print("The Target Impedance is", TargetImpedance)
    params['Target Impedance'] = TargetImpedance

    value.append(params.copy())

    df = pd.DataFrame(value)
    df.to_csv('Values.csv')

    Val = 1/(abs(Zc - TargetImpedance) + 100*Lossval)
    return Val

0 个答案:

没有答案