CSV with comments

GinTon jonasmg at softhome.net
Tue Jul 18 11:48:49 EDT 2006


GinTon wrote:
> In csv.reader, is there any way of skip lines that start whith '#' or
> empty lines
> I would add comments at my CSV file

For skip comment I get a dirty trick:

reader = csv.reader(open(csv_file))
for csv_line in reader:
    if csv_line[0].startswith('#'):
        continue

But not possible let blank lines.

I think that CSV class should to let skip comments and new lines of
auto. way.




More information about the Python-list mailing list