08-09-2013 04:44 PM
Hi all,
I just switch to CVI from labview. In labview coding, it is pretty easy to operate string. But in CVI, I don't find the string library. I am looking for something like "Array to Spreadsheet String". I have an array of int. The size of the array is not fixed. I have to convert each integer in the array to a string and separate each number with delimiter ",", also I need to add a given string as prefix. But in CVI, I didn't see any function like "Array to Spreadsheet String". I know something simple on C and I think I might need to allocate the variable for string first. But since the number of decimal places of each number of the array is different, how can I tell how big of string I need to allocate for the string? or is there any function or library in CVI will do the same thing like "Array to Spreadsheet String"? Thanks.
08-10-2013 05:53 AM
If you are new to CVI it may worth spending some time dogging into the library menu, where yuo can find several useful resources available.
Coming to your question, there isn't a built-in equivalent to that LabVIEW VI, but you can use sprintf (from the Ansi C library) of Fmt (from the Formatting adn I/O one) with the appropriate formatting strings to obtain the same result. An additional resource can be ArrayToFile command, which directly outputs the result to a file on disk.
01-26-2016 04:00 PM
I'm asking the same question. This is the type of toolkit that in my opinion should exist. Since ansi c gets messy when you need a three dimensional array of allocated pointers to manage this, there really should be a function that loads a spreadsheet table into a two dimensional array of cstring objects.
What is the simplest way to parse a tab deliminated spreadsheet file at the moment?
01-27-2016 04:19 PM
Hi Steve_Block,
Are you working with Excel? LabWindows/CVI ships with a library called Excel Report (documentation attached below) which adds some functionality for interacting with Excel spreadsheets.
Also, I would recommend posting a new thread to the LabWindows/CVI forums, as older threads tend not to get as much exposure and are less likely to generate replies.
Function Tree, Excel Report: http://zone.ni.com/reference/en-XX/help/370051V-01/toolslib/toolslibexcelreport_functiontree/
01-29-2016 07:31 AM
I'm not working with excel in this scenario. I simply want an easy way to parse a tab deliminated text file without a huge amount of overhead allocating memory.
02-01-2016 06:09 PM
Hi Steve,
There are currently no built in functions that can read/parse a csv file, or other delimited files, and place them into an array or table in CVI. You will need to create the array/table yourself. I recommend reading in the file as an ASCII/text file and parsing the text using tokens and storing the values into a 2D array. I also suggest formatting the string to the data type you are expecting.
char *strtok(char *str, const char *delim)
You may also want to look at the FileToArray function in CVI. You won't be able to create a 2D array but it may save a step by reading in either a single row or column in at a time.
02-02-2016 05:30 AM
Hi Steve,
based on the code provided by Nick in this discussion I created a small sample project that imports a file into a 2D array of strings. It dynamically adapts to the number of rows in the file but considers a fixed number of fields in the lines. It may be of help for you to develop the proper file parser.
02-02-2016 07:32 AM
That is similar to what I did in my code, but this is the first time I've seen a 4 level pointer. I'm thinking more along the lines of a BSTR which allows you to work with a 2d array. It would be nice to have a built in object that serves as a table equivalent of a BSTR.