Skip to content

Instantly share code, notes, and snippets.

@Siddhartha90
Created January 26, 2014 00:31
Show Gist options
  • Save Siddhartha90/8626071 to your computer and use it in GitHub Desktop.
Save Siddhartha90/8626071 to your computer and use it in GitHub Desktop.
Py script to convert a text file containing data to a mahout datafile format, which is values separated by commas(CSV)
def main():
myfile = open('words.txt', 'r')
outfile = open('wordsoutput.txt', 'w')
for line in myfile:
line_list = line.split('::')
new_line = ','.join(line_list[:-1])
outfile.write(new_line)
outfile.write('\n')
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment