(Apr-12-2017, 01:43 PM)wavic Wrote: Let's break it to simple tasks.
I am supposing that each line is formated like: id tweet text
# open the input file and read it. with open('input.txt', 'r') as in_file: # read each line for line in in_file: #open an output file for writing #get the first element for the output file's name elements = line.split() with open('{}.txt'.format(elements[0]), 'w') as out_file: # write the rest of the line into the file out_file.write(' '.join(elements[1:])) #It's basically this.
man I really was Depressed, thanks aloooooot
(Apr-12-2017, 01:43 PM)wavic Wrote: Let's break it to simple tasks.
I am supposing that each line is formated like: id tweet text
# open the input file and read it. with open('input.txt', 'r') as in_file: # read each line for line in in_file: #open an output file for writing #get the first element for the output file's name elements = line.split() with open('{}.txt'.format(elements[0]), 'w') as out_file: # write the rest of the line into the file out_file.write(' '.join(elements[1:])) #It's basically this.
I tried it and it worked perfectly, but is there any way to specify the path that new files will go in?