Hello Ventuzians!
THE FORUMS ARE CLOSED!

Please join our discord server HERE!! << click me :D

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server

Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!

Save text to CSV file

Q and A about functionality and how to solve a special task for your application.

Moderator: Support

Post Reply
User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Save text to CSV file

Post by Chris » 26 Mar 2016, 22:49

Hi All,

I have created a basic form to collect some text and save it out in CSV format.
I'm not the best in the world at scripting......so would someone mind having a quick look over my scene and letting me know if I can improve the script
in any way??

Is this the most efficient way to create as CSV file in Ventuz?

I also wanted to force some rules for the text that is entered in the boxes, i.e. not allowing the text to be added to the file unless a valid email address is entered.
Would anyone know how I can accomplish this??

The scene is pretty basic at this point, but any other suggestions on the scene as a whole are also more than welcome :D

Thanks
Chris
Attachments
Text to CSV.vza
(34.39 KiB) Downloaded 253 times

joschy
Posts: 142
Joined: 19 Jan 2012, 07:39
Location: Düsseldorf, Germany
Contact:

Re: Save text to CSV file

Post by joschy » 29 Mar 2016, 14:53

may be you already found this: https://social.msdn.microsoft.com/Forum ... m=netfxbcl
I can't load your file currently, it's PLE. Don't know how large your file is and there is a for loop, you should use the thread class https://msdn.microsoft.com/en-us/librar ... 71%29.aspx
3DJo - [Ventuz] freelancer and trainer

User avatar
Chris
Posts: 108
Joined: 14 Aug 2012, 09:10
Location: UK

Re: Save text to CSV file

Post by Chris » 29 Mar 2016, 21:59

Hey,

Thanks for the reply joschy :)

Here's my code

Code: Select all

//if file doesnt exist, create file
		
		if (!File.Exists(filePath))
		{
			File.Create(filePath).Close();
		}
		
		// Append line to the file.
		
		using (StreamWriter writer = new StreamWriter(filePath, true))
		{
			writer.WriteLine(Data);
		}
       
		changed = true;
It all works fine, just wondering if there is anything I should change to make it better??

Cheers
Chris

Post Reply