02-23-2009 03:28 AM
Hi...
In my application ,i have an array that i have to write to text file.so before writing to text file,am converting the array to spread sheet format,
using array to spread sheet conversion.
The array i am converting is a 2D array.Suppose the array contains 6 elements. as follows
2009-02-23 16:32:00+04.210-00.002-00.002-00.002+00.000-00.004+00.002-00.002
2009-02-23 16:31:00+04.216-00.002-00.004+00.002-00.004-00.002-00.002+00.002
2009-02-23 16:29:59+04.214-00.002-00.002-00.002+00.000+00.002-00.002-00.004
2009-02-23 16:28:58+04.216-00.002-00.002+00.000-00.002-00.002+00.000-00.002
2009-02-23 16:27:58+04.210-00.002-00.002-00.002+00.000-00.004-00.002+00.000
2009-02-23 16:26:57+04.210-00.002-00.002-00.002-00.002-00.002-00.002-00.002
2009-02-23 16:25:56+04.210-00.002-00.002-00.002-00.002-00.002-00.005-00.002
2009-02-23 16:24:56+04.216-00.002-00.002-00.002-00.002+00.000-00.004-00.002.
What i have to do is,have to delete the first element from the array and convert to spread sheet string and then to write to the text file.
The result of array to spread sheet conversion is correct..it resu,lt me as follows..which is correct...
2009-02-23 16:31:00+04.216-00.002-00.004+00.002-00.004-00.002-00.002+00.002
2009-02-23 16:29:59+04.214-00.002-00.002-00.002+00.000+00.002-00.002-00.004
2009-02-23 16:28:58+04.216-00.002-00.002+00.000-00.002-00.002+00.000-00.002
2009-02-23 16:27:58+04.210-00.002-00.002-00.002+00.000-00.004-00.002+00.000
2009-02-23 16:26:57+04.210-00.002-00.002-00.002-00.002-00.002-00.002-00.002
2009-02-23 16:25:56+04.210-00.002-00.002-00.002-00.002-00.002-00.005-00.002
2009-02-23 16:24:56+04.216-00.002-00.002-00.002-00.002+00.000-00.004-00.002
But after writing to text file,the only thing being written is the following
2009-02-23 16:24:56+04.216-00.002-00.002-00.002-00.002+00.000-00.004-00.002
All other data lost....I cudnt find where am going wrong...
Pls guide me on this.
Am attaching a sample code as attachment...
Thanks in advance
02-23-2009 04:50 AM
Hello
this is because, whenever you are opening the file, index will be 0.. & then you write anything, it will overwrite the previous data ...
For your requirement, you have to use "Write to Spreadsheet String.vi".. please see the attachment.
02-23-2009 04:52 AM
HI
First close the connection after writing to file, then open the new connection and read the file.
Hope this helps
Regards
Santosh
02-23-2009 07:30 PM - edited 02-23-2009 07:31 PM
Hi Rajan,
Thanks for ur reply.
I cud only find write to spreadsheet file.vi...and using that cant input 2d array of string.
I was unable to locate write to spreadsheetstring.vi..I am using labview 8.0.
Am attaching my code after changing...
Please guide me on this.
Thanks again...
02-24-2009 09:02 AM
Hello
I need not read & close the ref ... just create the file first .. & then keep on appending the data to it .. If you can upload the VI, it would be easy for me..
02-24-2009 09:24 PM
02-24-2009 10:27 PM
Hi user_1,
To my understanding, Write to Spreadsheet.vi in LabVIEW 8.0 can only write 1D/2D Numeric Array. Hence, you may want to consider using Array to Spreadsheet method again.
Let me summarise your problem. Your problem is when you read back from your read (as shown in array to spreadsheet.jpg), you only manage to read 1 element in your array. The rest of the 6-7 elements are missing. Please correct me if I am wrong.
The reason to your problem is because of the write to file pointer. For the 1st time, you write 8 elements (there is 8 rows in your 1st 2D array in your post). The 2nd time, you write 7 elements (7 rows in your 2nd 2D array). Because you use 'open', the 2nd time you write will replace row1-7 data in your text file. The pointer now rest at the end of row 7. So when you read after that, you will read row 8 (which is element 8 in your 1st 2D array).
To solve your problem, you should modify your vi to something similar to the picture attached below. This will reset the pointer to the start of the file before reading the data in the file. By doing this way, you will read all the datas in the file.
This problem do not occurs if you only open, read and close file (not open, write, read, close file). The pointer is reset to the start of the file when you use Open File function.
Hope this solve your problem.
Regards
Lee
02-25-2009 10:19 PM
Hi ...
I cud fix the thing by changing theVI," Write to Spreadsheet file.vi" according to my need.Thanks for all helps!!!!