+ Reply to Thread
Results 1 to 3 of 3

Thread: how to: read csv files into rhino python

  1. #1

    how to: read csv files into rhino python

    Hi, i have a little question about how can i read CSV (or excel) files into rhino with python , i know that python comes with a CSV modulo , so my question itīs about how can i use it....

    thanks

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    Hi Diego,
    The standard library csv module does not work with Rhino's implementation of python (http://www.ironpython.info/index.php/Reading_CSV_Files)

    Fortunately many csv files are pretty easy to read. Here's a basic sample that reads a file and adds points to Rhino
    Python Code:
      import rhinoscriptsyntax as rs
      file = open("C:\\Users\\a-steve\\Desktop\\Worksheet.csv", "r")
      lines = file.readlines()
      file.close()
       
      for line in lines:
          tokens = line.split(',')
          tokens = [float(item) for item in tokens]
          rs.AddPoint( tokens )

    Attached is the csv file that I read in with the above script.
    Attached Files

  3. #3
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,464
    Blog Entries
    19
    another thing to mention is that you can also directly communicate with excel if you want to go that route

    http://www.ironpython.info/index.php...ing_with_Excel

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts