Answer the question
In order to leave comments, you need to log in
How to convert from 3 columns of google spreadsheets to 1 column in python?
It is necessary from these columns -
Convert one column -
Here the principle is that it is necessary to write values \u200b\u200bin the main column without repetitions. That is NOT so
I settled on the fact that I wrote down each column in a list. Here is the code -
from pprint import pprint
import gspread
import httplib2
import apiclient.discovery
from oauth2client.service_account import ServiceAccountCredentials
# Файл, полученный в Google Developer Console
CREDENTIALS_FILE = 'my-python-food-dbddaae45da9.json'
# ID Google Sheets документа (можно взять из его URL)
spreadsheet_id = '1Ohtq7Mxw_L4FR0Vpi_aQxidorgfFv0l5q9ECtLS84g4'
# Авторизуемся и получаем service — экземпляр доступа к API
credentials = ServiceAccountCredentials.from_json_keyfile_name(
CREDENTIALS_FILE,
['https://www.googleapis.com/auth/spreadsheets',
'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("Первый тестовый документ").sheet1
data = []
data = sheet.col_values(2)
print(data)
data1 = []
data1 = sheet.col_values(4)
print(data1)
data2 = []
data2 = sheet.col_values(6)
print(data2)
Answer the question
In order to leave comments, you need to log in
Now just add the three lists plus and then make a set() set from the resulting redundant list. Only unique values will remain.
The order will not be preserved.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question