Copy external data & paste as 2D wave
ChrLie
I often need to copy data from something like Excel into Igor, but I usually want 2D waves instead of single columns. My present solution is ok, I execute
edit
then copy & paste and call this little snippet:
function tab2matrix()
string tabName = WinName(0,2)
string list = wavelist("*",";", "WIN:"+tabName)
DoWindow/K $tabName
Concatenate/DL/KILL/NP=1 list, data
end
string tabName = WinName(0,2)
string list = wavelist("*",";", "WIN:"+tabName)
DoWindow/K $tabName
Concatenate/DL/KILL/NP=1 list, data
end
but I was wondering if there is a better or even native way to do this. I could make it slight more efficient if I convince
getscrapText()
to paste into a table, but I haven't found a way so far.
Anyone an idea?
Thanks!
How about something like:
LoadWave /G/M "Clipboard"
December 1, 2022 at 07:27 am - Permalink
Just some quick ideas without really testing them:
- save GetScrapText() string into temporary text wave on disk and then invoke LoadWave. EDIT: OK, it seems LoadWave is even able to load from the clipbaord directly. Neat!
- parse GetScrapText() string manually (line breaks to rows and tabs to columns). For this, see also Tony's somewhat related code snippet: https://www.wavemetrics.com/node/20912
- if you want to paste the whole excel table, rather load the excel file directly?
December 1, 2022 at 07:27 am - Permalink
In reply to How about something like: … by KurtB
I only want pieces of the excel file. Usually columns with headers as dimlabels. I thought about saving and re-loading, but it seemed a bit clunky. I like Tony's idea to count \r and \t to get the dimensions of the matrix. That could be a way to paste cell by cell based.
hmm, that looks very interesting, in particular if this works with the /U flag to get at least column labels - I need to play with that!
Thanks both!
EDIT:
actually, that does exactly what I want. I haven't even hoped for row labels initialy!
LoadWave/U={1,0,1,0}/J/M "Clipboard"
December 1, 2022 at 07:55 am - Permalink