This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list = os.listdir(path) | |
# Files are now named ssn_filename_uniqueid.filetype | |
# Set files to list ['filename','unique_id','file_type'] | |
def renameFiles(list): | |
name = [] | |
for filename in list: | |
name.append(re.split("(_\d*_\d*_\d*)", filename)) | |
return name | |
def getFiles(list): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
# First get the folder name (SSN) and save it | |
folderlist = [name for name in os.listdir(".") if os.path.isdir(name)] | |
# Second get filelist on folder | |
def new_list(x): | |
for ssn in x: | |
for filename in os.listdir(ssn): | |
new_name = str(ssn) + '_' + str(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
# First get the folder name (SSN) and save it | |
folderlist = [name for name in os.listdir(".") if os.path.isdir(name)] | |
# Second get filelist on folder | |
def new_list(x): | |
a = {} | |
for i in x: | |
a[i] = {'old_name' : os.listdir(i)}, {'new_name' : os.listdir(i)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function composeData($file){ | |
$f = fopen($file, 'r'); | |
while(!feof($f)) | |
{ | |
$line = fgets($f); | |
if(empty($line)) | |
return; | |
$lineData = explode('|', $line); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$questions = array('TherapygroupQuestions' => | |
array('id' => 1,'question' => "How much this hurt?"), | |
array('id' => 2, 'question' => "How much your feet hurt?"), | |
array('id' => 3, 'question' => "How much your hand hurt?") | |
); | |
$answers = array('TherapygroupAnswers' => | |
array('id' => 3, 'question_id' => 1, 'answer' => 1), | |
array('id' => 5, 'question_id' => 3, 'answer' => 5) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for($i=0;$i<count($kysymykset);$i++){ | |
if(count($vastaukset) > 0){ | |
foreach($vastaukset as $key){ | |
if ($kysymykset[$i]['TherapygroupQuestions']['id'] == $key['TherapygroupAnswers']['question_id']) { | |
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions'], array('vastaus' => $key['TherapygroupAnswers']['vastaus'], 'vastaus_id' => $key['TherapygroupAnswers']['id'])); | |
} | |
} | |
}else{ | |
$kysymykset_vastaukset[$i] = array_merge($kysymykset[$i]['TherapygroupQuestions']); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have two arrays, questions and answers. I need to merge them together so in question there are its answer if it have answer. | |
This is how it should look like: | |
array(‘questions’ => | |
array(‘id’=> 1, | |
’question’ => ‘How sick you are’, | |
‘answer’ => 3)) | |
And if there are no answer it should only show the question. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PodcastTableViewController.swift | |
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PodcastTableViewController: UITableViewController, DataParserObserver { | |
var podcasts = [Podcast]() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.podcasts = [Podcast]() | |
let dataParser = HttpRequesting() | |
dataParser.httpGetPodCasts(parserObserver: self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func httpGetApi () { | |
let parameters: Parameters = ["username": "username", "password": "password"] | |
Alamofire.request("addr", method: .post, parameters:parameters, encoding: JSONEncoding.default) | |
.responseJSON{response in | |
if let json = response.result.value as? [String: String] { | |
self.setApiKey(apiKey: json["api_key"]!) | |
}else{ | |
self.setMessage(statusMessage: "Ei toimi") |
NewerOlder