DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read data chanels from a file?

Solved!
Go to solution

Hi,

 

I have some .CSV files, that have inside tree chanels( load force; opening force;travel distance) captured from two motors.

I want to load more CSV files and analyze only two chanels ( opening force  and  travel distance) and send them to a report (travel distance to X-axis, and Opening force to Y-axis), but in the report to be all the chanels from all the CSV files that I loaded. ( to do a multi-load)

 

My question is how can I read from the csv files the chanels that I am interested and then analyze them?

 

I use this exemple from HELP to load the data:

 

Dim MyFileNames, iCount
Call FileNameGet("ANY", "FileRead","D:\BOF-MIU\BOF Archive\", "CSV data (*.CSV),*.csv", "All.lst", True, "Data selection":smileywink:
MyFileNames = Split(FileDlgFileName,"|":smileywink:
For iCount = 0 To Ubound(MyFileNames)
  Call DataFileLoad(MyFileNames(iCount))
Next

' and then I try to analyze, but I don't know how to split the csv file to get only the chanels that I want

Call ChnSmooth(filedlgfile &"[1]/Axis 1: Position (uu)","/Smoothed",12,"maxNumber":smileywink: '... Y,E,SmoothWidth,SmoothType

 

Thank you for your time.

0 Kudos
Message 1 of 9
(5,307 Views)

Hi ,

 

I find this thread, with this package of scripts :  ResultsList Advanced Menus Add.zip (18 KB), and I try to see if it is something that can help me with a multiload data, but I was lost in all the function that are there. I must find a way that I can read the chanels that are inside of a csv file, and put the chanels from more csv files in to a  custom report.

Please tell me what function can I include in my script, and realize reading the channels data from the file and analyze them.

I attached some csv files to see how the data are in the file.

Sorry for  bother you but I have to finish this multiload until sunday.

 

Thank you again.

0 Kudos
Message 2 of 9
(5,305 Views)

Hi,

 

I succed with loading channels from the csv files , but I encounter another problem: I can load more then one csv file, and if I try with for z=1 to 50, (like in my script) the script will search until the 50's file, (I thing) because I have only 7 files and he is askink for the 8 files:

  Error in <NoName(1).VBS> (Line: 15, Column: 3):
     Cannot find "BOF1_20081106008.csv" file.

 

My script so far is:

 

Dim MyFileNames, iCount, i, j,z

Call FileNameGet("ANY", "FileRead","D:\BOF-MIU\BOF Archive\", "CSV data (*.CSV),*.csv", "All.lst", True, "Data selection")
MyFileNames = Split(FileDlgFileName,"|")
For iCount = 0 To Ubound(MyFileNames)
  Call DataFileLoad(MyFileNames(iCount))
  '-------------------------------
 For z=1 to 50
  Call DataFileLoadSel(left(filedlgfile,15)&z & ".csv","csv","[1]/[3,4]","load")
  Next

'-------------------------------------------------------------------------------
Call ChnSmooth("Axis 1: Position (uu)","Travel Distance"&i+1,12,"maxNumber") '... Y,E,SmoothWidth,SmoothType
Call ChnSmooth("Element 2: Comms value","Opening Force"& j+1,12,"maxNumber") '... Y,E,SmoothWidth,SmoothType
'-----------------------------------
For i=1 to 50
Call ChnSmooth("Axis 1: Position (uu)"&i,"Travel Distances" & i+1,12,"maxNumber") '... Y,E,SmoothWidth,SmoothType
next
'------------------------------
For j =1 to 50
Call ChnSmooth("Element 2: Comms value"&j,"Opening Force" &j+1,12,"maxNumber") '... Y,E,SmoothWidth,SmoothType
next

next

 

If I remove the "z" he will give another error :

 

 17:00:32 Error:
 Cannot interpret channel name in "("Axis 1: Position (uu)7","Travel Distances8",12,"maxNumber")" command.

 

What I want to do is to load a certain numbers of csv files, extract from each csv file there the two channels( Axis 1: Position (uu) and Element 2: Comms value) and to represent on a graph

[Axis 1: Position (uu)]i / [Element 2: Comms value]i.

 

Please give me a "hand" with this. I have post it before a folder with the csv files, maybe it will help you.

 

Thank you again for your time and your patience.

0 Kudos
Message 3 of 9
(5,292 Views)

Hi Marse,

 

I'm very pleased that the "CSV" DataPlugin that ships with DIAdem enabled you to load your data files, that's one step down.  I think I understand what you mean by "I don't know how to split the csv file to get only the chanels that I want".  I think you want to load only the last 2 channels from each selected CSV file.  Here's how to do that-- first select the CSV files you want to load in the NAVIGATOR, then run the following VBScript

 

FilePaths = GetNaviSelFiles()

IF NOT UBound(FilePaths) > 0 THEN Call AutoQuit("No CSV files selected in the NAVIGATOR")

Call DataDelAll

FOR j = 1 TO UBound(FilePaths)

FileName = NameSplit(FilePaths(j), "N")

Call GroupCreate(FileName)

Call GroupDefaultSet(GroupCount)

Call DataFileLoadSel(FilePaths(j), "CSV", "[1]/[3-4]")

ChnName(CNoXGet(GroupCount, 1)) = "Opening Force"

ChnName(CNoXGet(GroupCount, 2)) = "Travel Distance"

NEXT ' j

 

Function GetNaviSelFiles() Dim i, j, iMax, Elements, FilePaths

Set Elements = Navigator.Display.CurrDataProvider.Browser.SelectedElements

j = 0

iMax = Elements.Count

ReDim FilePaths(iMax) FOR i = 1 TO iMax

IF Elements(i).IsKindOf(eComputerFile) OR Elements(i).IsKindOf(eSearchFile) THEN

Path = Elements(i).Properties("FullPath").Value

IF UCase(NameSplit(Path, "E")) = "CSV" THEN

j = j + 1

FilePaths(j) = Path

END IF ' CSV file

END IF ' Selected NAVIGATOR File

NEXT ' Selected NAVIGATOR Element

 ReDim Preserve FilePaths(j)

GetNaviSelFiles = FilePaths

End Function ' GetNaviSelFiles()

 

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 4 of 9
(5,291 Views)

Hi Marse,

 

For viewing purposes, you might consider the old "channel expansion mode", which lets you configure one curve (Opening Force vs. Travel Distance) in the REPORT dialog, yet automatically shows all N curves for the data loaded from N CSV files.

 

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 5 of 9
(5,287 Views)

Hi Brad,

 

Thank you for the script, but I want to mentione that I control Diadem from a OLE interface, from a VBA application,  and I need to give to Diadem to run the script and select the csv files from a msgdialog box, not to select the files in the navigator panel,

I thing I have to use the command :

Call FileNameGet("ANY", "FileRead","D:\BOF-MIU\BOF Archive\", "CSV data (*.CSV),*.csv", "All.lst", True, "Data selection")

 to get a window were I can select the files, but were to put this command ?

 

0 Kudos
Message 6 of 9
(5,284 Views)

Hi,

 

Regarding to the script that you give to me, I try to modify it to make it suitable for my application, to chose the channels from a window, not to chose them from the navigator panel, and then to analyze them (smooth them), and after that to represent them on a graph, but with no succes.

Please tell me how can I implement the FileNameGet command(and the DatFileLoad) with the smooth command to the channels.(or if there are other commands that can to that)

And what kind of modification you do to the report to represent the group, because I don't know how you did that to have only one curve on the "Curve and axis definition", and still in the report to have more curves and diferent colors( how you split the curve).

Sorry if put stupid question or I didn't find out by myself, I try , but with no succes.( I need more knowledge of Diadem, a lot) 

 

 

0 Kudos
Message 7 of 9
(5,226 Views)
Solution
Accepted by topic author Marse

Hi Marse,

 

Here is the file dialog approach you requested-- use this in place of the "FilePaths = GetNaviSelFiles()" command in the script I sent you:

 

DlgTitle = "Insert File Dialog Title Here..."

StartPath = ProgramDrv & "Libr\Dat\"

FileExts = "*.DAT;*.TDM"

Call FileNameGet("Any", "FileRead", StartPath, FileExts, "Nul", True, DlgTitle)

FilePaths = Split("|" & FileDlgFileName,"|")

 

The trick in the TDR file I sent you was to configure it for "exanding mode" in the "Layout Parameters" dialog.  This is an old display option that can cause trouble if used in the wrong situations, but it seemed like it would make your life easier for this particular task.

 

Brad Turpin
DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 9
(5,197 Views)

Hi, 

 

I find out that, but now I need to know how can I analyze ( smoth, delete) from a group channel.

(Please look at the threat:   "smooth a group channel" )

 I need to know that, because I have to smooth the channels, and cut "the data way back" to 0  from the report.

 

Thank you for all your help.

 

 

0 Kudos
Message 9 of 9
(5,190 Views)