Importing Excel Files


jlward

Recommended Posts

Hello, very new to DAQFactory. I have downloaded your free trial version. I have data in an Excel file from another user that I would like to import back into DAQFactory to play around with and learn how to use it. How can I import an Excel file back into DAQFactory? Thank you... sorry if my questions seems silly, I have not used DAQFactory before.

Link to comment
Share on other sites

First, you'd need to save your excel file as a csv file, making sure your dates are in numbers, not in 5/5/2010 type format. Then you would use the File. functions to open and read the file in script. You'd use File.Open, File.ReadDelim() and File.Close()

If you just want to play with the graphs, you might just consider creating a Test channel. You can add noise to a test channel by creating a conversion like this:

Value + randuniform(-0.1,0.1,1)

Link to comment
Share on other sites

I'm still having a tough time with this....

I can export fine and dandy, but when it comes to reading the file and placing the data into variables, that is where I'm getting stumped.

How do I place the data into variables?

Sorry, I'm still very confused on this subject.

Link to comment
Share on other sites

If you use readdelim() its going to return a 2 dimensional array corresponding to your data. Presumably you have time in the first column. So, lets say you put the result of readdelim() into a variable called datain; something like datain = file.readdelim(...)

To then extract each column, you do: datain[][x] where x is the column you want. So, if time is in the first column, it might be something like this:

variableA = datain[][1]

variableA.time = datain[][0]

variableB = datain[][2]

variableB.time = datain[][0]

etc.

Link to comment
Share on other sites

  • 2 weeks later...

After reading the section about reading/placing file data, I finally got this to work -

private handle = File.Open("C:\DaqFactory\Data\Variables.csv", 1, 0, 0, 1)
private varsin = File.ReadDelim(Handle, -1, "," , chr(10), 0)
v.var[0] = var[][1]
v.var[1] = var[][2]
v.var[2] = var[][3]
v.var[3] = var[][4]

Is the -1 in the readdelim() forcing DF to read the whole .csv file?

Glad it's working though. :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.