P
P
PILITYXXX1232020-08-10 22:02:33
Python
PILITYXXX123, 2020-08-10 22:02:33

How to convert from 3 columns of google spreadsheets to 1 column in python?

It is necessary from these columns - 5f31972f12814709798285.png

Convert one column - 5f31978dcca30590098096.png

Here the principle is that it is necessary to write values ​​\u200b\u200bin the main column without repetitions. That is NOT so

5f3198d50c383601511442.png

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

1 answer(s)
A
Alan Gibizov, 2020-08-10
@PILITYXXX123

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 question

Ask a Question

731 491 924 answers to any question