Odd Excel data?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Odd Excel data?

Post by AxWald » Mon Oct 17, 2016 1:31 pm

Hi,
In the "old excel format" (*.xls) you have to watch an area like this:

ASCII:

Code: Select all

þÿþÿü ... [Values] ÿ
Hex:

Code: Select all

FE FF FE FF FC ... [Values] FF
But do I get this right? Your light meter is connected via USB, and has a front end program that itself constantly writes the data to an existing Excel spreadsheet? (Without invoking Excel itself)

Or does the front end program just call Excel to write the data? (Excel should start itself when recording)

Or is the front end program actually an Excel macro or a VBA module? (You need to start Excel/ an Excel document to start recording)

In the latter 2 cases some VB/VBS/VBA should be involved. So I'd attack the front end program and all its files with a trusty text/Hexeditor, and look for "Visual basic looking stuff" that might be modified for easier access.
But not before I had looked after what Richard mentioned:
FourthWorld wrote:Does it offer any simpler, more common options?
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Odd Excel data?

Post by dunbarx » Mon Oct 17, 2016 2:45 pm

AxWald.

Thanks for the homework. I will write back as soon as I have either figured this out, or become even more bogged down.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Odd Excel data?

Post by dunbarx » Mon Oct 17, 2016 4:11 pm

Well, changing the spreadsheet to "CSV" fixes all the odd formatting and zipping stuff. Works fine. Only cell data is returned. LC reads happily and continuously while I am in Ecxel.

The problem is that LC will only read disk file contents, not (I think) the "live" contents held in RAM. In other words, all works fine except that live changes I make to the spreadsheet are only reflected back in LC if I save the spreadsheet. This is not an untended process if I have to hit cmd-"S" every interation of the read cycle. I am trying to set up a self-running data logging thingie.

I do not believe that LC can save another application. But I bet AppleScript can, or a shell command can.

So my last problems as a beginner is this:

How do I save the excel spreadsheet from within LC?
More importantly, how do I dismiss the inevitable dialog box that comes up each time I do save, since it warns me that in my CSV spreadsheet I will lose functionality unless I save it in a more normal (like .xls) format. I do not see a way to "never show me this dialog again", but I will ask around in the Microsoft Office" world.

Thanks for keeping with me on this.

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Odd Excel data?

Post by FourthWorld » Mon Oct 17, 2016 4:22 pm

If I understand this correctly, you have a device that can output plain-text CSV logs, and you want to periodically process that with a tool you're making in LiveCode. What is Excel needed for in this workflow?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Odd Excel data?

Post by dunbarx » Mon Oct 17, 2016 4:57 pm

Richard.

The light meter, and I have only read its specs, not actually played with it, states that it can write continuous CSV data via USB to a computer, loading into excel. Some sort of front end app manages the device. The output contains information such as intensity, color spectrum and other measured data.

I cannot, in a one day session, simply take that entire days output and process it. If that were the case, I would be done. I have to do it "live" as information changes based on changes in the environment.

Craig

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Odd Excel data?

Post by jameshale » Mon Oct 17, 2016 9:37 pm

If you have not actually played with it perhaps you are jumping ahead a bit.
Your description could be interpreted as the device is simply writing and appending to a cvs file which can be used by excel.
If this is the actual case then it can also be used by any other program.
Can't LC simply read from the file at set intervals, determine the appended data and proceed to process it?
Or, is excel a required interface to the device?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Odd Excel data?

Post by dunbarx » Mon Oct 17, 2016 9:45 pm

James.

A good question, and I will research more, but the specs do say it writes to excel.

In any case, the more fundamental question is whether it is possible at all to read from any document whose changes have not been saved. In other words, to read from the current state in RAM, as opposed to a saved state on disk. I suspect that is a bit thorny.

Craig

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Odd Excel data?

Post by jameshale » Mon Oct 17, 2016 10:25 pm

At this stage that is not at all clear.
While excel may be holding its working version of a document in RAM it seems highly unlikely to me that the device is feeding this. This would imply that excel is talking directly to it which makes no sense if you can set the device to output a cvs file.
More likely excel is repeatedly reading from the cvs file, as you want LC to do.
But all this is just fanciful speculation until you actually investigate the device.

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Odd Excel data?

Post by AxWald » Tue Oct 18, 2016 10:58 am

Hi,
dunbarx wrote:In any case, the more fundamental question is whether it is possible at all to read from any document whose changes have not been saved.
For sure you can read from disc until kingdom comes. But until it's saved to disc you'll not read much new data ;-)
dunbarx wrote:In other words, to read from the current state in RAM, as opposed to a saved state on disk.
If the data are in RAM, there must be a process owning these data. Question is, what process. If it's Excel, you can ask it via VB for the data. If it's the front end program, well, we don't know how to talk to it. But since it's writing Excel data there's a chance that it's just some VB script itself. That may be analyzed/ modified/ talked to.

Another idea: Have you tried to read from USB with LC? Something like mentioned here:

Code: Select all

open driver "COM2:" for binary update
read from driver "COM2:" for 1 line in 100 milliseconds
This may work even better.

Interesting stuff! :) Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply