1.

Write a program create csv files data with sapces at the beginning?

Answer»

import csv

csv.register_dialect(‘myDialect’ ,delimiter = 7,skipinitialspace=True)

F=open(‘c:\ \pyprg\ \sample2.csv’ , ’r’)

reader= csv.reader(F, dialect= ’myDialect’)

for row in reader:

print( row)

F.close( )

OUTPUT

[‘Topic 1’ , ‘Topic2’ , ‘Topic3’]

[‘one’ , ‘two’, ‘three’]

[‘Example 1’ , ‘Example2’ , ‘Example3’]



Discussion

No Comment Found