P
P
pilityxxx2020-08-10 15:19:42
Python
pilityxxx, 2020-08-10 15:19:42

How to write all values ​​from column B of google spreadsheets to a list in Python?

The result should be like this - clients = [[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected] gmail.com, [email protected], [email protected], [email protected], [email protected], [email protected]]

Data should be taken from this table - 5f313a89b82a0121095416.png

I'm stuck here -

from pprint import pprint
import gspread
import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials

# File retrieved from Google Developer Console
CREDENTIALS_FILE = 'my-python-food-dbddaae45da9.json'
# ID Google Sheets document ( can be taken from its URL) spreadsheet_id =
'

1Ohtq7Mxw_L4FR0Vpi_aQxidorgfFv0l5q9ECtLS84g4 ' ', ' https://www.googleapis.com/auth/drive ']) httpAuth = credentials.authorize(httplib2.Http()) service = apiclient.discovery.build('sheets', 'v4', http = httpAuth ) client = gspread.authorize(credentials) sheet = client.open("First test document").sheet1 client1 = [] data = sheet.col_values(2)



clients = ''.join([str(x) for x in data])

client1.append(clients)

print(client1)

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
P
PavelMos, 2020-08-10
@pilityxxx

clients = ''.join([str(x) for x in data])
at the beginning it says [[email protected], [email protected], ....., but here join is empty '', it will glue them into a solid line, and not into a comma + space
", ".join( ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question