[Tutor] (no subject)

Luke Paireepinart rabidpoobear at gmail.com
Fri Sep 15 01:25:56 CEST 2006


John Fouhy wrote:
> On 15/09/06, timothyh at email.arizona.edu <timothyh at email.arizona.edu> wrote:
>   
>> This is the first time I have posted to this list so I hope I am asking
>> appropriate question in acceptable way. Want I want to do is take a file and
>> cut it into pieces so each piece is a new unique file; the new files would be
>> one line (newline) from the file I want to cut up. The file  I want to cut up
>> has 3900 lines. This is as far as I have got.
>>     
>
> So, you want to create 3900 different files, then?
>
> What do you want to call these files?
>
> You can iterate through each line of a file like this:
>
> input = open('/Users/timothy/Desktop/t' , 'r')
> for line in input:
>     # ...
>   
Good example, except you shouldn't use 'input' since it's a builtin.
:D
Cheers.
-Luke
> So, in the body of the for loop, all you would need to do is decide
> what to call the new file, open the file, write line to it, and then
> close it.
>
>   



More information about the Tutor mailing list