Importing CSV from Google Sheets removes commas


Apologies for what may be a total noob question. I have searched this forum and others for answers to this and I am getting desperate. Thanks.

I am importing data from a live google sheets page into my app via a CSV file. I basically just add the URL to the properties of the web object and then “call web1.get” the read the table.

It reads the table just fine. I then use a “list from CSV table” to assign the records to a list.

My problem is that the “list from CSV table” call seems to strip out all the commas between the fields and it adds parentheses to the front and back of each record.

For example:

abc, 123, xyz, 789
def, 456, tuv, 456


(abc 123 xyz 789)
(def 456 tuv 456)

I need the commas to parse out the fields in subsequent code. I can’t use the spaces because some fields may contain spaces. And the parentheses are just plain annoying.

Any advice would be gratefully accepted. Thanks.

Try this:

1 Like

@Anke, thank you so much for the suggestion. Unfortunately, I don’t think that solution will work. As I mentioned, the text fields may contain embedded spaces (and parentheses for that matter), so I think your code would replace those spaces with commas and thereby mess with my downstream parsing.

Hello David - well of course it does, that function is intended to populate a table with the data - the commas are not data, they are value delimiters.

How do you observe the presence of parentheses?

I think you simply need to import the CSV data “raw” and immediately perform your downstream parsing, which may or may not include removing end-of-line (end of row) characters (and perhaps eventually the commas?).

Then show us a few concrete examples instead of this:

abc, 123, xyz, 789
def, 456, tuv, 456

Your problem arises from not using the appropriate list blocks to
retrieve items from your table.

Read the How to Work With Lists article in FAQ Section: Lists and avoid applying text blocks to lists.

Puede probar a cortar los elementos usando la coma.
Te los dividirá en una lista.
Puedes volver a añadirlos a otra nueva lista uniendo los items con espacios intercalados.

Enlace: cómo cortar texto en una parte.

Coloca los bloques al revés, donde dice segment: coloca la coma. En donde dice remplacement: coloca el espacio

Thank you, everyone for your help. I am a total noob at this. I ended up populating a list with the lines of the raw CSV file using "split text at “\n” " and then parsed each line using "split text at “,” ". It works perfectly now. Thank you all again.

1 Like

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