Can Someone Help me Solve this

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dolilmao
    New Member
    • Apr 2014
    • 1

    Can Someone Help me Solve this

    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

    Code:
    import csv
    block=[]
    f=open("file.txt", "r")
    csv_reader=csv.reader(f)
    for row in csv_reader:
       block.append(tuple(row))
    This function does not work can someone help me conquer this
  • stdq
    New Member
    • Apr 2013
    • 94

    #2
    What are you trying to accomplish with variable block?

    Comment

    • dwblas
      Recognized Expert Contributor
      • May 2008
      • 626

      #3
      I don't know what
      This function does not work
      means. It prints fine for me.
      Code:
      test_data="""river, 5
      -400, 400
      -333, 400
      300, 500
      
      sand, 5
      555, -200
      600, 554
      334, 432
      4332, 43"""
      with open("./test.txt", "w") as fp_out:
          fp_out.write(test_data)
      
      import csv
      block=[]
      f=open("./test.txt", "r")
      csv_reader=csv.reader(f)
      print "\nInput file is"
      for row in csv_reader:
          print row
      f.close()

      Comment

      Working...