03-03-2017 04:01 AM
Sorry lol just found it easier to do that than to skip back and forth reading other folks replies to reply. Sorry!
Will have a look when I get over to the lab. I'll move the file name logic to the inside of the loop.
I know what I want it to do, and were I doing it in python I would know what to do (I'm not a python expert but I know enough to cobble bits together) but doing it with block diagrams in Labview is taking a little learning (I'm a nuts and bolts bloke, give me an engine to rebuild or put a welder in my hand or give me an installation that needs electrically connecting I'm in my element! Coding is a new trick, I've only been learning for 6 months).
03-03-2017 05:18 AM - edited 03-03-2017 05:27 AM
Brilliant! I have followed the advice so far... And have something useable. Ok it's not elegant, but it writes a CSV file for each second, which works for us. Ok it means millions of files but that's not problem.
It would be a little more polished if I could get it to write to a single file... So... I changed the name format and removed the %H%M%S which worked. But... I have messy looking files with the headers written for each line. I can just drop the headers completely, since our script will know which value is for which gauge, but it would be nice to have the header once in each file.
Now, originally, it did not write the header for each value, but now i have modified it again it does. I will attach snippets of each example.
"ORIGINAL" was after I modified this VI to actually write to a CSV and pointed it to our shared drive. This meant that it would start writing a file (name defined by user) and keep going until it threw a wobbler about file size, full buffers etc. It would write a CSV like this:
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-1.2496866,2.5364521,-1.8014401,0.0735139,4.6753462,5.4407770,-0.8405562,-0.7300256,3.4263687,-1.0311767,-0.3316167,-0.4792480
3.0139500,-0.4778823,-0.8455739,0.8821662,6.9399668,0.6937904,-0.3289133,3.1391099,3.2789980,-4.2720178,-4.1636314,2.3962402
-0.2205329,-0.4778823,-2.1690809,-0.1470277,3.8717711,-2.7386463,-0.1827296,-0.1460051,0.7736962,6.5553373,-1.2159277,4.0183104
0.5880878,0.6249230,-1.3602711,1.7643324,0.3652614,0.0365153,0.2558215,-3.5041229,7.6264334,0.4419329,-0.5526944,5.1979978
1.2496866,-0.6984434,-0.7720458,3.5286647,1.2418889,-2.3734935,0.1827296,-4.7451664,0.8473815,0.7365548,-2.9108574,0.9216308
"MODIFIED" is how I have it now. It automatically writes a new file when the program is started, presumably will write a new one when the date changes (since it wrote new files when I had it looking at the time as well as date), but it writes a file like this:
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-7.7913245,-0.8821580,-0.0000000,-2.6829615,-5.3685698,-3.0668787,1.4981778,-2.3357425,-4.4576124,1.9885515,3.7212220,-0.4792048
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-3.9691652,2.9405265,-0.8822530,-2.3889383,-0.3286879,1.4604184,3.9098786,-4.3065253,1.4367510,8.0278556,3.4264718,1.8799572
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-2.2785948,2.3524212,-4.9994341,-2.9034789,0.1826044,-1.8255230,-2.0097508,-4.0875495,-3.7944965,2.7250520,-0.1842189,-1.0689953
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-8.0853367,2.2053949,-1.7645061,-3.4915253,0.5478132,-0.7302092,-0.8404412,-5.0364449,0.9209943,2.5041018,1.5105951,-2.2485763
Mast 1 - Strain 1,Mast 1 - Strain 2,Mast 1 - Strain 3,Mast 1 - Strain 4,Mast 2 - Strain 1,Mast 2 - Strain 2,Mast 2 - Strain 3,Mast 2 - Strain 4,Mast 3 - Strain 1,Mast 3 - Strain 2,Mast 3 - Strain 3,Mast 3 - Strain 4
-10.0699195,1.2497238,0.6616898,-3.7855485,-1.4973562,-2.7017741,-1.2789323,-2.8466862,2.3209055,6.3339045,1.0684697,-2.5434715
I may well figure it out in the meantime but thought I would ask before I exhaust my ideas as I am pushed for time... I already instructed it to append to the file it has opened (having this as false just makes it overwrite the data rather than append it).
EDIT
I have removed the header for the time being, since it will just make the file unnecessarily large and we actually don't need it. I know why it is writing it each time (the loop says make a file that is the date, write the header, write the data, write the header, write the data etc). I get that. How to say "Write the header once then just write the data please" in block diagrams is escaping me at the moment.
03-03-2017 05:42 AM - edited 03-03-2017 05:43 AM
Hi Dave,
you programmed your VI to write the header row in each iteration.
And now you wonder why it writes a header line in each iteration???
When you need the header only as first row you should write it only as first row, directly after creating a new file.
Do you remember the pseudocode I gave above? IF "new date" THEN "create new file"…
Another hint: IF-THEN-ELSE usually translates to a CASE structure in LabVIEW!
03-03-2017 06:08 AM - edited 03-03-2017 06:09 AM
No no, I know why it is writiing it in each iteration. I know what I did wrong. What I couldn't figure out was the correct way to do it (again, learning, plugging away and slowly "getting it" but a huge way to go yet). I'm still tinkering, bare with me 🙂 I am on with a different job now (I have so many plates to keep spinning) but later on I will stick it in a case structure and play some more (more out of wanting to see if I can make it do it, rather than it needing to do it).
03-03-2017 06:17 AM - edited 03-03-2017 06:18 AM
Hi Dave,
What I couldn't figure out was the correct way to do it
WHILE IF filename changes /* aka start of new day */ THEN create a new file write header line once ELSE use old filename ENDIF write new data to file WEND
Again some pseudocode…
03-10-2017 04:45 AM
Thanks! All sorted!