0

I want to write data in csv file(myfile,csv) i a able to write them but data are being written interleaving one row in them that i don't want. there shouldn't be any blank row I have written below code using csv module

data=[['NAME', 'GROUP', 'AD-NAME'], ['XYZ', 'bb1', 'aplpha1-XYZ-EXVE'],['PQR', 'bbb', 'uhbk-PQR-FIVE'], ['123', 'xyz', 'odlj-123-TIVE'], ['XYZ', 'my_name', 'aplpha-XYZ-EXEcCEL']]
with open('D:\\project\\myfile.csv', 'w') as csvfile:
        csvwriter = csv.writer(csvfile)
        csvwriter.writerows(data)
Devesh Kumar Singh
  • 19,767
  • 5
  • 18
  • 37
  • The code works for me, I see 5 rows `NAME,GROUP,AD-NAME XYZ,bb1,aplpha1-XYZ-EXVE PQR,bbb,uhbk-PQR-FIVE 123,xyz,odlj-123-TIVE XYZ,my_name,aplpha-XYZ-EXEcCEL ` – Devesh Kumar Singh Jun 17 '19 at 19:27
  • One look into the documentation: `with open('D:\\project\\myfile.csv', 'w', ` **`newline ="")`** `as csvfile:` – Patrick Artner Jun 17 '19 at 19:27

0 Answers0