[New-bugs-announce] [issue14415] ValueError: I/O operation on closed file

thao nguyen report at bugs.python.org
Mon Mar 26 19:15:36 CEST 2012


New submission from thao nguyen <thaonphuong at gmail.com>:

Dear Support Team,

I have built a function (enclosed here) to merge many files (in this example is 2 files: "a1.txt" and "a2.txt") lines by lines. The output file is called "final_file". However, i could not have it run successfully.

Content of "a1.txt":
1
3
5


Content of "a2.txt":
2
4
6


Content of "final_file.txt" will be like:
1
2
3
4
5
6


In Python, i called just written module:

import argument
reload(argument)
argument.test(2,"C:/a1.txt","C:/a2.txt")

and get the error as below: 
     "ValueError: I/O operation on closed file
      File "c:\append.py", line 5, in <module>
              argument.test(2,"C:/a1.txt","C:/a2.txt")
      File "c:\argument.py", line 28, in test
             for line_data in f:"

Could you please advise the resolution for this?


Thank you

----------
components: None
files: argument.py
messages: 156833
nosy: thaonphuong
priority: normal
severity: normal
status: open
title: ValueError: I/O operation on closed file
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file25029/argument.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14415>
_______________________________________


More information about the New-bugs-announce mailing list