Jump to content

Problem with writing away data (its making me crazy)


Recommended Posts

Hey,

Well i have a question about writing away some data to a spreadsheet file.

Well this is the thing:

I have on my front panel a Table, so there are some columns and rows in it. Some off the data needs to be

written to a spreadsheet file, for being a header off the file, after that header needs to come some data, data that i get from tests that i'm doing(like temp, vibration, etc...)

So you what is now the problem?

This is really hard to explain but i will try anyways:).

The tests that are running generates lots off data, so that data will be writted away in 5-10mins, still not a reall problem and not that hard to program. The thing is that the data needs to be attached to a header from the table. Like in 1 row you get Temp 1.

I take that Temp 1 and after that i need the data. If i want to write away other data from Temp 3 (attached to Row 3) then i need to have a header and after that header all the data from temp 3 in like 5-10 mins (the time i want to write away the data).

This is what i cant get.

What i can get is like all the headers from the table and all the data after it but not like i want it, not like

Header

Data

data

data

Header2

data

data

data

....

I tried alot to get the thing done but it never works, i made alot off changes here and there, made subs and all...still the only thing i can get is:

Header

Header2

Data

data

...

or

header

header2

header

header2

data

header

header2

or

header

data

header2

data

(the last one is almost it, still i only get 1 data and its getting replaced in 5-10mins with new data and that also something i dont want, i need more data after it)

Still if you ppl want to try to help me out, i have attached the program that i made (its a simple one and if it works it will be implented into my other program)

Regards

Bart

Download File:post-2-1147815591.llb

Link to comment

Hi Bart:

Very helpful that you provided us with a way of looking at what you've already tried-- Many new users try to get help from us without showing us what they have already tried, when they do that, we can't help them at all (and often we don't even want to try).

I'm a little busy now, but since you let me see your code I can easily suggest some ideas which might help out.

Your comment in the code that the file headers should not be in the loop is absolutely correct :thumbup: But, perhaps more important, the file open dialog shouldn't be inside the loop either. :!:

Open the Write spreadsheet subvi which you are using and look at its diagram. Notice that every time it is called, it opens a file, writes some stuff to the file, and then closes the file. Probably what is happening it that the last time you run the loop, this file (with one data point in it)overwrites the file (also with one data point in it) which was written the second to last time you ran the loop.... What you want to do is take the insides of the write spreadsheet file and use them separately in your program.

Take the parts of the Write spreadsheet vi which get the file name and open the file and put them before your loop. Then write your header, then get your data and write it to the file, then run the parts which close the file. Use the file refnum wire to control the order in which the various parts of the file writing take place so the file gets written in the correct order.-- use the way it is done inside of write spreadsheet vi as an example of how to do this. (You also want to use the error cluster wire one wire alone will control flow, but both are good to have each for their own reasons-- you need the refnum wired to make the program work, and you need the error cluster wired to help you understand why it still doesn't work. :P )

Rely as much as you can on the data flow control of the program-- The file refnum, or "handle" gets passed from one part of the program to the next. It forces the various parts of the program to take place in the correct order. Most-- probably all-- of the sequence structures in your code are unnecessary. Study some examples-- such as the write spreadsheet file vi itself, and this should begin to make sense to you. to get the file Refnum and error cluster in and out of the loop, right click on the edge of the loop and make a shift register. (search online help for shift register for details.)

I think there may be a much easier way to do this-- I seem to recall a version of the write spreadsheet vi that includes an input for a line of column headers. In my opinion, however, there's two closely related reasons not to use it: (1) You'll learn more about LabView by doing it yourself. (2) Once you do it yourself, its easy to make more complicated files to serve your needs-- multi line headers, more than one array of data in the file, etc. There's also probably a way of using the string manipulation tools to add the header to the beginning of your data, and writing all the data and the header in one shot. Might be a little easier, but most important to understand the concepts of data flow control-- so put the energy into that first & later on, take a look at all the string manipulation tools & see how you might use them too-- they are powerful, but some are hard to learn to use. A million ways to write any program & others may have better suggestions than mine.

At any rate, hope these suggestions help at least a little let us know how things work out.

Best Regards, Louis

Link to comment

Hey,

Louis thanks for the reply, still there i have some questions about it.

First off all, if the the ON vi is in the loop the program isnt replacing all the data tho, its more like appending to it, cause you need to choose replace if you want to start writing it away, after you said 'oke replace it' then the data will be written away to the spreadsheet.

And its also for like, if you change something in the header then the data will be update. Then oke i understand that the header vi needs to be placed outside the loop, but then there will be the problem like,

how can i manage to make my data like

header

data

...

header2

data

...

etc...

cause normally i would use a concateneted string so that i can have like the header and then after that the data, but then the header and the data will always be written away. If there was a way to generate that header just 1 time and the data stream all the time, then i maybe can work.

You can see that i still have problem with this :D ...

Regards and many thanks

Bart

Link to comment

hey again :) ,

Well Louis :worship: i have great news, yes yes i have found out how i could write the data away like i wanted too:). And yes, there is a bit off your advice in the coding ;) , I cant thank you enough for it.

And if you want to see the code, let me know and i will put it on my space.

Regards

Bart

PS: I'm SOOOOO HAPPY :D

Link to comment
PS: I'm SOOOOO HAPPY :D

Glad we were able to help! & glad that you made progress on your own (partly because I've been really tied up since your earlier post, partly 'cause it is the best way to learn. :thumbup: )

I'll take a look at what you ended up with when I get a chance ( :nono: BTW, Crelf is right, better to put the file here rather than on your own ftp site-- easier for folks to join the discussion, easier for others who follow you to benefit from the historical record.)

Hope you learn to enjoy LabView & LAVA forum, both are wonderful tools.

Best Regards, Louis

Link to comment

Well here is the new code from my problem :) , changed a bit in it and well putted some comments in it too.

Also, Labview is indeed a bit new for me, i'm started using it from september:). My whole thesis is about that, programming a full vibrationtable for testing air filter.

Still i hope to learn more and i also will "try" to help ppl here. Still i'm not a vet like you guys, but i hope i will be one in some years:)

Regards

Bart

Download File:post-5037-1147959132.llb

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.