LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

about spreadsheet read or write

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.

0 Kudos
Message 1 of 11
(4,769 Views)

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



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 11
(4,773 Views)

@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);

 

0 Kudos
Message 3 of 11
(4,759 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 11
(4,757 Views)

@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.

 

 

0 Kudos
Message 5 of 11
(4,753 Views)

That's strange! On my machine (CVI 2012SPE on WinXP and Win7) it runs without errors: which release and OS are you using?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 11
(4,736 Views)

 


@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

0 Kudos
Message 7 of 11
(4,732 Views)

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.

0 Kudos
Message 8 of 11
(4,725 Views)

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?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 11
(4,711 Views)

@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

0 Kudos
Message 10 of 11
(4,708 Views)