python 2.7 - AttributeError: 'int' object has no attribute 'write' -


I am reading through a CSV file and writing the result to a logfile, "p.log". Although I am converting the data into a string before writing it in the file, and doing it successfully through many iterations, I am running in a situation where I finally get this error: AttributeError: Anyone in the 'int' object The attribute is not 'write'

I will provide a snippet of my code as well as the results printed on my screen:

  p = open ("p.log" , "w") line in line: line = line.split (",") print Line, type (str (line)) p.write ('string:' + str (line) + '\ n') [f * '14 -04-21 08: 30: 00.973000 ',' EEm 06211440.5p ',' EEm ',' 2014-06-21 ', '40 .50', 'P', '16084', 'Auto', 'PHLX', '0.82', '10', '0.82', '31 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 2 ',' 3 ',' 2 ',' Bidding ',' 31 ' '0.0000', '2', 'AN \ r \ n'] & lt; Type 'str' & gt; ['14 -04-21 08: 30: 007474000 ',' MU 06211425C ',' MU ',' 2014-06-21 ', '25.00', 'C', '0', 'Auto', ' PSE '' 1.57 ',' 11 ',' 1.56 ',' 11 ',' 1.67 ',' 30 ',' 0.11 ',' 0.01 ',' 0.10 ',' Y ',' Z ',' 1 ' 'IXH', '3', 'Mid', '0', '0', '0', '\ r \ n'] & lt; Type 'str' & gt; ['14 -04-21 08: 30: 9, 000 ',' QQQ04251481 c ',' QQ ',' 2014-04-25 ', '81 .00', 'C', '1585', 'Auto ',' AMEX ',' 5 ',' 1 ',' 5.20 ', '82', '5.70', '67', '0.50', '0.50', '0.00', 'Y', 'AINX', ' 4 ',' AINX ',' 4 ',' Ask ',' 67 ',' -22.3881 ',' 4 ',' Aynx \ r \ n '] & lt; Type 'str' & gt; ['14 -04-21 08:30: 00.976000 ',' MPL 05171435.66C ',' MPL ',' 2014-05-17 ', '35.66', 'C', '40 9 ',' Auto ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 0 ',' 3 ',' 20 ' '2', 'I', '1', 'Bid', '384', '94 .7917 ',' 2 ',' AI \ r \ n '] & lt; Type 'str' & gt; ['14 -04-21 08: 30: 0078 78000 ',' AAPL 7071 9 4500C ',' AAPL ',' 2014-07-19 ',' 500.00 ',' C ',' 670 ',' Auto ',' AMEX '34.85 ',' 3 ', '34.15', '1', '35 .05 ',' 12 ',' 0.90 ',' 0.70 ',' 0.20 ',' Y ',' A ',' 1 ',' A ',' 1 ',' Mid ',' 0 ',' 0 ',' 0 ',' \ r \ n '] & lt; Type 'str' & gt; Traceback (most recent call final): File "q1.py", line 83, & lt; Module & gt; P. Write ('string:' + str (line) + '\ n') Character: Any attribute in 'int' object is 'written'   

As you can see that many The lines are printed without fail to line it with 'AAPL' is not sure why there is an error on this line and not others.

Nowhere in the code is a line in your variable p Overwrites with integer

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -