A csv list instead of multiple variables

HI

I want to use a csv list instead of numerous variable in web request
i am stuck to translate the list in my google apps script

Regards

can you explain better your goal ?

hi

perhaps it's wrong thing but i want to send to my app
ten data in spite of use var1, var2, var3 etc
i made a list and send it to my app
in my app i know the order of the data so i might use them as i want
how can i retrieve data (perhaps a function like split ?°

Here is a simple demo to show you how to work with csv. There are two types a csv row and a csv table, these have to be handled differently to get the items out.

row.csv

cat,dog,cow,pig,sheep,horse

col.csv

cat
dog
cow
pig
sheep
horse

image

simplecsv.aia (3.3 KB)

hi

in 2 cases you got an array :
first 1 D
second 2 D
it's not the same to read it in my web app....

regards

Why not show some example data?

Your csv will either be a row or a table.....

i just use the block : list to csv row
(cola, sandwich, toyota, cat, blue) =>("cola", "sandwich","toyota","cat","blue")
instead of using a variable for each i would like use a list
but arrived in my web app how to "treat" this ?

I have added a third variant:

colrow.csv

cat,dog,cow,pig,sheep,horse
father,son,mother,daughter,aunt,uncle
road,town,city,state,country,code

image

image

image

Label1 show the selection of an item from the list.

You would use these blocks as a replacement for your variable:

image

Hi Em

Does the csv change often or is it just the current way the data is stored? I ask because that data could be a Block List in App Inventor, no csv file required.

Snap1

i use a list to export data to google sheets
i don't want to use it in app inventor

This isn't making much sense....

please show your relevant blocks, indicating where you need to input from this "csv"....

hi every body
thanks for helping me
i do explain in a wrong way
what i want ? is sending a comma separated value to my web app
my data is "cola";"sandwich";"toyota";"cat";"blue"

i saw this post it's about list and i can't use it

https://groups.google.com/forum/#!starred/mitappinventortest/RUpJhf8IJgk

regards

What is your web app? What does it do with the data it receives?

in this part is just displays this data in columns

i try this :

var test= eval("["+ e.parameters.dat +"]");

var a= test [1] ;
var b= test [2] ;
var c= test [3] ;

sheet.appendRow([a,b,c]);

it doesn't work

It is a google apps script setting data to a google sheet ?

If you are only sending three data items:

<ScriptURL>?item1=a&item2=b&item3=c

in the web app script:

function doGet(e) {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('<NAME OF YOUR SHEET>');

var x = e.parameter.item1;
var y = e.parameter.item2;
var z = e.parameter.item3;

sh.appendRow([x,y,z]);
}

If you change your web app script:

1 Open the script project
2 Go to Publish
3 Deploy as Web App
4 Project version: - select New from the dropdown
5 Execute the app as: your google account address (email)
6 Who has access to the app: Anyone, even anonymous
7 Press the Update button

You have to do this EVERY TIME you change your script

thanks TIMAI2 i know how to send 2 or 3 data
this time i have to send 25 data it's why i thought put it in a list
i think i have to learn something new ...

Follow this guide:

Export CSV data (multiple data) to Google Sheet

1 Like

hi

thanks for your support
logic was there but i did two errors :slight_smile:
I like to check what I'm doing with "call show alert notice" blocks but I forgot to store the result in a variable
on the other hand i forgot(one more time) a symbal equal in the request
everything is ok

thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.