By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Can Someone Help me Solve this

P: 1
I have been learning python for a few days now and needed something to put my mind into, I was searching for a way to create a map using turtle and came across this code on my computer I created a file.txt with the following coordinates:

river, 5
-400, 400
-333, 400
300, 500

sand, 5
555, -200
600, 554
334, 432
4332, 43

Expand|Select|Wrap|Line Numbers
  1. import csv
  2. block=[]
  3. f=open("file.txt", "r")
  4. csv_reader=csv.reader(f)
  5. for row in csv_reader:
  6.    block.append(tuple(row))
This function does not work can someone help me conquer this
Apr 20 '14 #1
Share this Question
Share on Google+
2 Replies


P: 94
What are you trying to accomplish with variable block?
Apr 30 '14 #2

Expert 100+
P: 614
I don't know what
This function does not work
means. It prints fine for me.
Expand|Select|Wrap|Line Numbers
  1. test_data="""river, 5
  2. -400, 400
  3. -333, 400
  4. 300, 500
  5.  
  6. sand, 5
  7. 555, -200
  8. 600, 554
  9. 334, 432
  10. 4332, 43"""
  11. with open("./test.txt", "w") as fp_out:
  12.     fp_out.write(test_data)
  13.  
  14. import csv
  15. block=[]
  16. f=open("./test.txt", "r")
  17. csv_reader=csv.reader(f)
  18. print "\nInput file is"
  19. for row in csv_reader:
  20.     print row
  21. f.close() 
May 1 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.