11-10-2013 11:03 PM
Hi there,
I am porting a labview code to labwindows. In the labview code, there are two functions called "Read From Spreadsheet File.vi" and" Write To Spreadsheet File.vi", I wonder what's the corresponding function in CVI do the same thing? Thanks.
11-11-2013 12:28 AM
If I remember well, those functions create a txt file with the content of the input arrau, something in the line of .a CSV file.
The closes equivalents should be ArrayToFile and FileToArray
11-11-2013 10:57 AM
@RobertoBozzolo wrote:
If I remember well, those functions create a txt file with the content of the input arrau, something in the line of .a CSV file.
The closes equivalents should be ArrayToFile and FileToArray
Thanks. I am trying to read a text file with 5 rows, each row has 255 integers separated by space. Here is my code but it crashes
int data[255];
FileToArray("data.txt", &rdata[0], VAL_INTEGER, 255, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_ASCII);
11-11-2013 11:05 AM
Does it return any error?
It seems to me that you should state 255 * 5 as the number of elements, since this command reads the entire file at once.
11-11-2013 11:36 AM
@RobertoBozzolo wrote:
Does it return any error?
It seems to me that you should state 255 * 5 as the number of elements, since this command reads the entire file at once.
It doesn't return any error just crashes. Yes, you are right, I should reserve big memory instead. Let's consdier simple cast, with text file with only 5 rows and 10 numbers in each row. I have my code like
int data[50];
FileToArray("data.txt", &data[0], VAL_INTEGER, 50, 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_ROWS, VAL_ASCII);
But again, it crashes. Even I enlarge the data to 100 size, it still crashes. I don't know if there is anything wrong in my code or not.
11-11-2013 05:21 PM
That's strange! On my machine (CVI 2012SPE on WinXP and Win7) it runs without errors: which release and OS are you using?
11-11-2013 05:29 PM
@RobertoBozzolo wrote:
That's strange! On my machine (CVI 2012SPE on WinXP and Win7) it runs without errors: which release and OS are you using?
I am using windows8 64-bit system. CVI 2013 ver13.0.0
11-11-2013 09:59 PM
I have some test on these problem and I found that there might be some limitation on the size of the array to read the file? I found that if I have the file containing more than 500 rows and each rows have 514 numbers. It still works. But if I add one more rows, it crashes. Also, I found that using FileToArray is pretty slow. It takes about 6 seconds to read a file contains 514*500 numbers.
11-11-2013 11:32 PM
Ok I was thinking to some general misbehaviour so I tested with your small file and not on a huger one...
I have found this thread that can add some detail on the function: it appears that you should be able to read at least double the amount of values than yours: the discussion dates back to 2002: I don't think more modern system have lesser limits but if you are running in the IDE, can you try with a compiled executable?
11-11-2013 11:49 PM
@RobertoBozzolo wrote:
Ok I was thinking to some general misbehaviour so I tested with your small file and not on a huger one...
I have found this thread that can add some detail on the function: it appears that you should be able to read at least double the amount of values than yours: the discussion dates back to 2002: I don't think more modern system have lesser limits but if you are running in the IDE, can you try with a compiled executable?
Thanks for the information. I try that code, it seems that FileToArray and ArrayToFile does have limit on the size. Since I ran into the same problem as the author of that post had, it only works for small size of array 😞 And FileToArray is pretty slow. I finally use fgets and sscanf to achieve it. Just wonder the document doesn't mention the limitation on the ArrayToFile