Welcome, Guest. Please Login.
OpenDX User Forum
05/21/13 at 11:26:12


Pages: 1
ImportSpreadsheet component names (Read 1464 times)
c.pospiech
Forum Newbie
*


Got Viz?

Posts: 6
ImportSpreadsheet component names
07/25/11 at 10:46:01
 
Hi,
 
I have problems to select a component from a field that was imported via ImportSpreadsheet.
 
The documentation says (quote) "Each column in the file is imported as a separate component in the resulting output field. The name of the component is taken from a name at the top of the column in the file, if present." (unquote).
 
If I put the left output tab from ImportSpreadsheet into VisualObject and this into Image, I see three components named "test1", "test2" and "test3" (which are precisely the contents of the first line of the spread sheet). Also, plugging the right output tab of ImportSpreadsheet into echo, I see the same three names.
 
So far, everything works as expected.
 
But if I now plug the left output tag of ImportSpreadsheet into Extract, and specify "test3" as the component to be extracted, I get the following error message.
ERROR: Extract: Missing data: input is not a field, or has no test3 component.
 
Explanations welcome !
 
Christoph Pospiech
Back to top
 
 
Email   IP Logged
joelr
OpenDX Forum Administrator
*****


Got Viz?

Posts: 388
Re: ImportSpreadsheet component names
Reply #1 - 07/25/11 at 12:30:39
 

Try using Print rather than VisualObject/Image. You'll get much more detailed
information on the exact structure of your field. (Set the print options to "rd").
Back to top
 
 
Email   IP Logged
c.pospiech
Forum Newbie
*


Got Viz?

Posts: 6
Re: ImportSpreadsheet component names
Reply #2 - 07/25/11 at 14:57:39
 
Thanks ! That was an excellent suggestion.
 
By comparison with the other component names like 'positions' and 'connections' I found that the component name in question was '"test3"' rather than 'test3'. Hence I had to enter "\"test3\"" for the second component of Extract - and it worked.
 
It seems that ImportSpreedsheet is responsible for adding these extra \". Any way to get rid of them ?
 
Christoph Pospiech
Back to top
 
 
Email   IP Logged
joelr
OpenDX Forum Administrator
*****


Got Viz?

Posts: 388
Re: ImportSpreadsheet component names
Reply #3 - 07/25/11 at 16:18:31
 

Hmmm... ImportSpreadsheet should not be adding anything. Are you
sure the quotes aren't in the input file?
Back to top
 
 
Email   IP Logged
c.pospiech
Forum Newbie
*


Got Viz?

Posts: 6
Re: ImportSpreadsheet component names
Reply #4 - 07/26/11 at 02:33:11
 
Hi,
 
in a sense, that is correct. The input file is a *.csv file with \t (TAB) as separator and \" (") as string delimiter. Apparently, ImportSpreadsheet doesn't recognize the \" as string delimiters, but as part of the string. I tried with recreating the *.csv file with string delimiter \' ('). But then even the print module with options "rd" couldn't hint me to the right way of specifying the right input for the Extract module. So I switched back to \", where I already worked around the problem (by using the Format module to add enclosing \" to the string).
 
In ImportSpreadsheet, there is a way to specify the separator. I missed something similar for the string delimiter.
 
Christoph Pospiech
Back to top
 
 
Email   IP Logged
joelr
OpenDX Forum Administrator
*****


Got Viz?

Posts: 388
Re: ImportSpreadsheet component names
Reply #5 - 07/26/11 at 04:34:52
 
If the column names are the only things that are quoted, you're
probably ok. You just need to escape the quotes, e.g.
       Extract(yourField, "\"test2\"")
(Or, as you discovered, you could use Format to add the quotes.)
 
If you also have string-valued data that's quoted, you'll find you cannot
remove the quotes within dx. (String handling definitely a weakness.)
I think you'll be happier if you use a tab-delimited format.
 
Cheers,
Joel
Back to top
 
 
Email   IP Logged
Pages: 1