2017년 1월 12일 목요일

Lists and Sublists


So what I'm trying to do is take data from a fusion table and create sublists inside a list.

The data returned from the fusion table is as follows:

(ROWID, NAME, POS
1001, Amanda, C
1002, Emily, T
1003, Marissa, P)

What I did was create a list by separating the rows, so now each row is an item in the list. (I used split text at \n)

the first item is ROWID, NAME, POS
the second is 1001, Amanda, C
etc...

But I am stuck on the next part. How do I separate each item so that it may have its own sublist

for example I wish the first item ROWID, NAME, POS to have sublists, where each item in the sublist is separated by the comma

ex item 1 in the sublist is ROWID
item 2 is NAME
etc...

I cannot find the most efficient way to do this.

--
What I did was create a list by separating the rows, so now each row is an item in the list. (I used split text at ∖n)
you should split at ∖n only for 1 column csv tables
for "more than 1 column csv tables" use the list from csv table block instead, which creates a lkst of list

How do I separate each item so that it may have its own sublist

to select the first sublist, use the select list item block together with the main list and index 1
to select the second item from the firest sublist, then use again the select list item block together with the sublist and index 2


-- 
Thank you so much!! That helped a lot.

One final question. I am using an update function to update a row in the fusion table, and am using a getRowID function to get the rowID so it knows where to put the new information. How do I get the rowID of a row in which a field is empty? 

For example I have used SELECT ROWID FROM table_id WHERE NAME = 'Amanda', POS = ________

Is there certain syntax it expects you to use when a field is empty? Should I just use an empty text string?

-- 
Should I just use an empty text string?
yes, like this (see below) and use AND to concatenate several conditions, see also https://developers.google.com/fusiontables/docs/v2/sql-reference#Select

SELECT ROWID FROM table_id WHERE NAME = 'Amanda' AND POS = ''

-- 

댓글 없음:

댓글 쓰기