001
## Script turns all lines from new_dataset in Trello Cards
import login, trello_api
from urllib.request import urlopen
def get_raw_data():
# Returns a list where each element in a line from new_dataset.txt
f = open("new_dataset.txt")
lines_for_cards = []
for line in f:
if line != "\n":
lines_for_cards.append(line)
return lines_for_cards
def find_needed_data_in(raw_data):
''' (list) -> list
Returns List of lists with [0] as name and [1] as comment
'''
clean_data = []
for element in raw_data:
caret = 0 # pointer at current symbol
name = "" # storage for name field
description = "" # storage for description field
# skip any symbols at the beginning of a line if not number
while element[caret].isdigit() != True:
caret += 1
# store a number, presumably associated with Client ID
while element[caret].isdigit() == True:
name += element[caret]
caret += 1
while element[caret] != "\n":
description += element[caret]
caret += 1
clean_data.append([name,description])
return clean_data
'''def make_card_for_trello_from(name, description_not_formatted):
(str, str) - > response
Returns respond to POST call from Trello about success in adding a new card.
description = format_for_url(description_not_formatted)
# URL for POST
request_url = API_URL + trello_list + "/cards?name=" + name + "&desc=" + description + "&key=" + key + "&token=" + token
return requests.post(request_url)'''
# take data from specific document
all_document = get_raw_data()
# find only lines with tasks
refunds_todo = find_needed_data_in(all_document)
# transform every fitting line in trello card
for data in refunds_todo:
trello_api.make_card_for_trello_from(data[0], data[1])
print("hi")