Hi everyone
I am trying to send (customized) bulk whatsapp messages using Pythonista and calling shortcut from within. I would like to retrieve list of people from CSV file and send the message with the recipient name and message body text.
Any help in this will be appreciated
Hello,
Here’s one way to read a csv file in Pythonista
import csv
with open('data.csv') as sourceData:
for row in csv.reader(sourceData):
print ('Name:',row[0],'Number:',row[1])
and here is the data.csv that it processes
"Millicent Bulstrode","+44 1234 123456"
"Peter Pettigrew","+44 1234 123457"
"Sirius Black","+44 1234 123458"
"Bellatrix Lestrange","+44 1234 123459"
"Penelope Clearwater","+44 1234 123460"
Running the script should output the following
Name: Millicent Bulstrode Number: +44 1234 123456
Name: Peter Pettigrew Number: +44 1234 123457
Name: Sirius Black Number: +44 1234 123458
Name: Bellatrix Lestrange Number: +44 1234 123459
Name: Penelope Clearwater Number: +44 1234 123460
The reader
function in the csv
module will return one row of the csv data as a list, you can then process the list as I have done in the example to get to the name and the number separately.