0

I am new in python. In my python script I want to export data to CSV file. What i did i have created a number.csv file in the folder where my python script is. I am using python 3.6.6. I have tried too many examples, but none of is working. Here is my code :

import csv

nms = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12]]
with open('number.csv', 'w',newline='') as f:
    writer = csv.writer(f)
    for row in nms:
        writer.writerow(row)
2
  • 1
    You haven't given many details on what the problem is. That code should work and write a new csv (well, except for the extra newlines introduced because you didn't use newline='' in the open) containing two rows of data. What happens instead for you? Commented Jul 3, 2018 at 18:13
  • working fine with me Commented Jul 4, 2018 at 15:16

1 Answer 1

2

Code is working fine, nothing wrong in the code. The problem is I was looking the csv file where my python python script file is, but the csv file is generating in the current user's folder.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.