06-11-2009 02:12 PM
06-12-2009 02:14 AM
FileToArray can split the content of a file into several groups: playing with the options of FileToArray command you can accomodate the function so that it can read several file types.
You can look at the attached example: it's the standard arrayfile example that ships with CVI (it's located into sample\fileio folder) that I have modified to treat a two-dimensional array both in writing and reading.
06-16-2009 02:39 PM
Thank you for your response. However, it does not seem to work if the file I am opening is in not written in CVI. When I try to copy the 1d it said that it was not initialized. Basically, I need to open a file (not necessarily from CVI) put it into an array and then plot it. I really appreciate this.
06-17-2009 05:31 PM
Hi Jemellie,
Can you tell us what line of code is the error coming from? What's the exact text of the error?
06-24-2009 10:38 AM - edited 06-24-2009 10:41 AM
The problem is when I plot it, its just a straight horizontal line at zero, when clearly its not supposed to be that way.
if (FileSelectPopup ("", "*.txt", "*.txt", "Name of File to Read",
VAL_OK_BUTTON, 0, 0, 1, 0, file_name) > 0){
GetCtrlVal (panelHandle, PANEL_InputType, &fileType);
FileToArray (file_name, array, VAL_DOUBLE, COUNT, 1,
VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, fileType);
Copy1D (array, COUNT, xonea);
Copy1D (array + COUNT, COUNT, yonea);
/*for(i=1; i=COUNT; i++){
xonea[i] = xoneb[i]/10000;
yoneb[i] = yoneb[i]/10000;
} */
DeleteGraphPlot (panelHandle, PANEL_GRAPH_3, -1, 1);
PlotXY (panelHandle, PANEL_GRAPH_3, xonea, yonea, COUNT, VAL_DOUBLE, VAL_DOUBLE,
VAL_THIN_LINE, VAL_NO_POINT, VAL_SOLID, 1,VAL_BLUE);
}
Thank You!
06-24-2009 10:57 AM
Hi Jemellie,
is the file you are trying to read an ASCII file or a binary file? In the first case I never had problems with FileToArray even with files produced by other programs: you may have to fiddle a little with command options but you are very likely to succeed. If you can post here a small sample of this file, we may try to help you in a more concrete way.
In case your file is a binary one, you may find problems if the other application does not stores data as CVI expects. Being this the case, can you detail a little how your file is created (type of data stored in it, organization of data within the file...)? Again, a small file sample together with relevant informations about it can help us in driving you to the correct way.