I'm newbie as with python as programming, poor English also...
I have a doubt, I'm using suds to get methods from a WSDL and then sometimes it returns me type instance or type text, when it returns me instance I could manipulate the object like a list, but like a text I couldn't, so I try to parse it, but it's too big, and the structure of the text there are a lot of "\n", so I thought, maybe I can read and treat like a file.txt and for each "\n" I get a list element. But I have no idea how I can turn a string or "Text" in .txt Can you help me?
my python.py:
#!/usr/bin/python
from suds.client import Client
import xml.etree.ElementTree as ET
url = 'https://gpadev.servicedesk.net.br/dataservices/application/clients/clients.asmx?WSDL'
d = dict(http='******', https='********')
client = Client(url, proxy = d, username= '******', password = '********')
method = client.service.Export('*******')
type (method)
it returns me:
type text
if a print, I get something like:
CLIENT,FULLNAME,SEX,NICKNAME,BOSS,TITLE,MANAGER,INACTIVE,NETID,EMAILID,EMAILALT,NOTIFYMAIL,PAGERNUMBER,NOTIFYPAGER,PHONELBL1,PHONE1,PHONELBL2,PHONE2,PHONELBL3,PHONE3,ADDRESS,ADDRESS2,ZIP,CITY,STATE,DIVISION,REGION,LOCATION,ORGUNIT,CHARGE,SLEVEL,SKILL,LANGID,TIMEZONE,NOTES,CLIENT_LIST_MANAGELEVEL,ANALYST_LIST_PROFILE **\n** CLIENT,FULLNAME,SEX,NICKNAME,BOSS,TITLE,MANAGER,INACTIVE,NETID,EMAILID,EMAILALT,NOTIFYMAIL,PAGERNUMBER,NOTIFYPAGER,PHONELBL1,PHONE1,PHONELBL2,PHONE2,PHONELBL3,PHONE3,ADDRESS,ADDRESS2,ZIP,CITY,STATE,DIVISION,REGION,LOCATION,ORGUNIT,CHARGE,SLEVEL,SKILL,LANGID,TIMEZONE,NOTES,CLIENT_LIST_MANAGELEVEL,ANALYST_LIST_PROFILE **\n** .......**\n** .......**\n** .......**\n**
thanks for helping me
There are at least two things in your question:
For the first thing: it's as easy as calling lines=method.split('\n')
, then you
can iterate through the returned lines
list.
For the second thing:
with open("path to save the file + filename.txt", "w") as f:
f.write(method)