'How to detect if user has allowed or ignored to download configuration profile from Safari?
For Installing mobile configuration profile to device I have opened SFSafariViewController
with profile url and after presenting, it will start to download profile automatically with user permission. It works perfectly. But I need to know whether user has allowed to download profile or ignored from SFSafariViewController
alert. Is it possible to know?
Code for opening Safari
let safariVc = SFSafariViewController(url: url)
safariVc.modalPresentationStyle = .overFullScreen
safariVc.delegate = self
safariVc.presentationController?.delegate = self as? UIAdaptivePresentationControllerDelegate
self.present(safariVc, animated: true, completion: nil)
My SFSafariViewController
snapshot is given bellow. Inside it there is a default alert asking for permission to download configuration profile. I just want to detect programatically what the option user has tapped. Is it possible to detect programatically?
Solution 1:[1]
You need to read over your input CSV row-by-row, and for each row, transform it, then write it out:
import csv
with open('output.csv', 'w', newline='') as f_out:
writer = csv.writer(f_out)
with open('dataset_elec_4000.csv', newline='') as f_in:
reader = csv.reader(f_in)
# comment these two lines if no input header
header = next(reader)
writer.writerow(header)
for row in reader:
# row is sequence/list of cells, so...
# select the cell with your sentence, I'm presuming it's the first cell (row[0])
data = row[0]
data = data.lower()
# need to put data back into a "row"
out_row = [data]
writer.writerow(out_row)
Solution 2:[2]
Python contains a module called csv for the handling of CSV files. The reader class from the module is used for reading data from a CSV file. At first, the CSV file is opened using the open() method in ‘r’ mode(specifies read mode while opening a file) which returns the file object then it is read by using the reader() method of CSV module that returns the reader object that iterates throughout the lines in the specified CSV document.
import csv
# opening the CSV file
with open('Giants.csv', mode ='r')as file:
# reading the CSV file
csvFile = csv.reader(file)
# displaying the contents of the CSV file
for lines in csvFile:
print(lines)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zach Young |
Solution 2 | Sakthi Bala K.S |