Monday 15 August 2011

Writing list to text file not making new lines python -


I'm having trouble writing to a text file. Here's my code snippet.

ram_array = map (str, ram_value) cpu_array = map (str, cpu_value) iperf_ba_array = map (str, iperf_ba) iperf_tr_array = map (str, iperf_tr) opening #with (ram, w ') As F: in # ram_array for: # f.write (s +' \ n ') # open (cpu,' w ') as F: # in cpu_array: write #f + '\ N') (iperf_b, 'Mau') as open with f: for iperf_ba_array s: f.write (s + '\ n') with f.close () open (iperf_t, 'mau' ) S for iperf_tr_array: f.write as f (s + '\ n') f.close ()

Both Ram and CPU work lossless, but when for iperf_ba A file Write for and write iperf_tr they always look like this:

  [45 9 47383.0, 470 9 760 9.0, 46576113.0, 47041787.0, 472 9 73 9 4.0]  

Instead

  1 2 3  

They are both from the global list. Values ​​are added between 1 and 1 in CPU and RAM, but otherwise they see the same pre-processing

How are they doing here

  file name = "iperfLog_2015_03_12_20: 45: 18_123 _____ tag_33120L06.csv "write_location = self.tempLocation () location = (stit_location) + str (file name)); Df = pd.read_csv (location, name = list ('abcdefghi')) transfer = df.h transfer = transfer [~ transfer.isnull ()] # panda to remove nan transfer = transfer.tolist () Length = integer (lane (transfer)) extra = length -1 transfer [extra] bandwidth = df.i bandwidth = bandwidth [~ bandwidth; gen ()] bandwidth = bandwidth (Bandwidth) bandwidth [extra] iperf_tran.append (transfer) iperf_band .append (bandwith) 
P> [from the comment]

You need to use. Extension (list) If you want to add a list to the list - and do not worry: we sometimes class-idiots-I spend all hours pursuing mistakes / debugging;)


No comments:

Post a Comment