Grasshopper

algorithmic modeling for Rhino

I want to write a CSV file from VB. This must be an easy one. Suggestions?
Thanks,Chris

Views: 553

Replies to This Discussion

Why don't you just stream the contents from a Post-it Panel? You can save as a .csv or .txt very easily... and no VB required. If you're data is coming out of a VB component, just dump it into a Post-it panel and stream the contents as normal.
HTH,
Andy
Hi Andy,
I want to write several fields at once into the file, separated by commas.
-Chris
I guess I could use the Function component and concatenate all of my fields together and then stream it. Hey, I think that would work fine and easy.
If you find that the Panel Streaming function isn't giving you what you need, the easiest way to write to a file is:

System.IO.File.WriteAllLines()
System.IO.File.WriteAllText()

I recommend using a StringBuilder to create the file contents as opposed to updating a String all the time by appending small segments. Much less memory overhead.

--
David Rutten
david@mcneel.com
Seattle, WA

Has this gotten any easier since this post from three years ago? Is there a built in component for writing files now, or a plug in that does it?

Thanks!

No in-build component yet.

--
David Rutten
david@mcneel.com
Poprad, Slovakia

Now that I think about it, I guess there really isn't a reason the Panel can't be used for this in all cases. No need for built in.  

It would be nice to be able to write multiple files (i.e. each branch in a datatree becomes its own file).

--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service