[Tutor] text file to excel csv file using python programming

Kent Johnson kent37 at tds.net
Wed Nov 26 03:43:58 CET 2008


On Tue, Nov 25, 2008 at 6:16 PM, Gilbert <pixelspics at gmail.com> wrote:
> Hi People,
>
>     I tried to look for some answers but I see only same data format
> processing ( *.txt to *.txt ) in python.
> my question is how to convert a text file ( e.g. *.log, *.dlg ) to excel
> *.csv using python programming.

This kind of program can be pretty simple, depending on the format of
your text file. It generally will have the form
open input file
open output file
open csv writer for output file

for each line in input:
  split the line into fields
  write the fields to the csv writer

close input file
close output file


The real program may not be much longer than that. I really depends on
what you need to do with the input lines. Can you show an example?

Kent


More information about the Tutor mailing list