Reading From an Excel Sheet
Hi all, I want to write a python script which reads in data from the excel sheet .Can any one help out in this ...any help will be appreciated. Thanks in Advance Sagar Meesala -- http://mail.python.org/mailman/listinfo/python-list
Reading Data From an Excel Sheet
Hi all, I want a python script which takes in input an EXCEL sheet and then reads the data in it. Any code snippets will be fine and this i want this in windows XP . Thanks in Advance Sagar Meesala -- http://mail.python.org/mailman/listinfo/python-list
Importing a csv file
Hi all ,
I want to read data in a csv file using the python scripts.
when i gave the following code :
import csv
reader = csv.reader(open("some.csv", "rb"))
for row in reader:
print row
it is showing :
Traceback (most recent call last):
File "csv.py", line 1, in
import csv
File "C:\Documents and Settings\meesa02\csv.py", line 2, in
reader = csv.reader(open("some.csv", "rb"))
AttributeError: 'module' object has no attribute 'reader'
im a total fresher to this python...SO can any one help me out in
this...
Thanks in advance
Sagar Meesala
--
http://mail.python.org/mailman/listinfo/python-list
SSL certificate issue
Hi, I am facing SSL certificate issue working with python. Can you help me on this. Thanks, Neha DXC Technology India Private Limited - Unit 13, Block 2, SDF Buildings, MEPZ SEZ, Tambaram, Chennai 600 045, Tamil Nadu. Registered in India, CIN: U72900TN2015FTC102489. DXC Technology Company -- This message is transmitted to you by or on behalf of DXC Technology Company or one of its affiliates. It is intended exclusively for the addressee. The substance of this message, along with any attachments, may contain proprietary, confidential or privileged information or information that is otherwise legally exempt from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate any part of this message. If you have received this message in error, please destroy and delete all copies and notify the sender by return e-mail. Regardless of content, this e-mail shall not operate to bind DXC Technology Company or any of its affiliates to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. -- https://mail.python.org/mailman/listinfo/python-list
Problem with running python 3.6.0 on a 32 bit windows 7 ultimate operating system.
I am new to python, I've been using C++ as as a student till last 3 years. To expand my knowledge, I installed Python 3.6.0 and when tried to open it, a pop up window appeared saying- "The program can't start because api-ms-win-crt-runtime-|1-1-0.dll is missing from your computer. try reinstalling the program to fix this problem." I tried repairing the software using the setup, but again it was the same. What else can I do to run Python on my system. -- https://mail.python.org/mailman/listinfo/python-list
[no subject]
Couldn't install any module from pip Plz help??? -- https://mail.python.org/mailman/listinfo/python-list
[no subject]
I'm not able to install pip in my pc it gives following error. what should I do? -- https://mail.python.org/mailman/listinfo/python-list
Correct Way to Write in Python
Hi All,
Im new to Python. Im coming from C# background and want to learn Python.
I was used to do following thing in C# in my previous experiences. I want to
know how do I implement below example in Python. How these things are done in
Python.
[code]
public class Bank
{
public List lstCustomers = new List();
private string micrcode;
public void Bank()
{
customer
}
}
public class Customer
{
private srting customername;
public string CustomerName
{
get { return customername; }
set { customername = value; }
}
}
main()
{
Customer objCustomer = new Customer;
objCustomer.CustomerName = "XYZ"
Bank objBank = new Bank();
objBank.lstCustomer.Add(objCustomer);
}
[/code]
--
http://mail.python.org/mailman/listinfo/python-list
Re: Correct Way to Write in Python
On Saturday, August 3, 2013 12:17:49 PM UTC+5:30, Peter Otten wrote: > [email protected] wrote: > > > > > Hi All, > > > > > > Im new to Python. Im coming from C# background and want to learn Python. > > > I was used to do following thing in C# in my previous experiences. I want > > > to know how do I implement below example in Python. How these things are > > > done in Python. > > > [code] > > > public class Bank > > > { > > > > > > public List lstCustomers = new List(); > > > private string micrcode; > > > > > > public void Bank() > > > { > > > customer > > > } > > > > > > } > > > > > > public class Customer > > > { > > > private srting customername; > > > > > > public string CustomerName > > > > > > { > > > get { return customername; } > > > set { customername = value; } > > > } > > > } > > > > > > main() > > > { > > > Customer objCustomer = new Customer; > > > objCustomer.CustomerName = "XYZ" > > > > > > Bank objBank = new Bank(); > > > objBank.lstCustomer.Add(objCustomer); > > > > > > } > > > [/code] > > > > While I don't know C# I doubt that this is good C# code ;) > > Here's a moderately cleaned-up Python version: > > > > class DuplicateCustomerError(Exception): > > pass > > > > class Customer: > > def __init__(self, name): > > self.name = name > > > > class Bank: > > def __init__(self): > > self.customers = {} > > def add_customer(self, name): > > if name in self.customers: > > raise DuplicateCustomerError > > customer = Customer(name) > > self.customers[name] = customer > > return customer > > > > if __name__ == "__main__": > > bank = Bank() > > bank.add_customer("XYZ") > > > > I'm assuming a tiny bank where every customer has a unique name and only one > > program is running so that you can ignore concurrency issues. Thanks a lot Peter. I appreciate your Help. You mentioned that C# code above is not good. If you can point me why it is not good, would help me learn new approaches as this type of Code I use to see long back(when i was fresher). There may be better approaches or concepts i am not aware of. If you can point me in that direction it would be gr8. -- http://mail.python.org/mailman/listinfo/python-list
Re: Correct Way to Write in Python
On Saturday, August 3, 2013 1:50:41 PM UTC+5:30, Steven D'Aprano wrote:
> On Fri, 02 Aug 2013 23:18:47 -0700, punk.sagar wrote:
>
>
>
> > Hi All,
>
> >
>
> > Im new to Python. Im coming from C# background and want to learn Python.
>
> > I was used to do following thing in C# in my previous experiences. I
>
> > want to know how do I implement below example in Python. How these
>
> > things are done in Python.
>
>
>
> I am not an expert on C#, but I'll try to translate the following code to
>
> Python.
>
>
>
>
>
> > [code]
>
> > public class Bank
>
> > {
>
> >
>
> > public List lstCustomers = new List();
>
> > private string micrcode;
>
> >
>
> > public void Bank()
>
> > {
>
> > customer
>
> > }
>
> >
>
> > }
>
> >
>
> > public class Customer
>
> > {
>
> > private srting customername;
>
> > public string CustomerName
>
>
>
> Do you mean "private string" rather than "private srting"?
>
>
>
>
>
> > {
>
> > get { return customername; }
>
> > set { customername = value; }
>
> > }
>
> > }
>
> >
>
> > main()
>
> > {
>
> > Customer objCustomer = new Customer;
>
> > objCustomer.CustomerName = "XYZ"
>
> >
>
> > Bank objBank = new Bank();
>
> > objBank.lstCustomer.Add(objCustomer);
>
> >
>
> > }
>
> > [/code]
>
>
>
>
>
> Here is a literally translation, as best as I can understand the C# code.
>
> (But note that this is not the best Python code.)
>
>
>
>
>
> class Bank:
>
> def __init__(self):
>
> self.lstCustomers = [] # Empty list of customers.
>
> self._micrcode = '' # Does this actually get used?
>
>
>
> class Customer:
>
> def __init__(self):
>
> self._customername = ''
>
>
>
> @property
>
> def CustomerName(self):
>
> return self._customername
>
>
>
> @CustomerName.setter
>
> def CustomerName(self, value):
>
> if not instance(value, str):
>
> raise TypeError('names must be strings')
>
> self._customername = value
>
>
>
>
>
> if __name__ == '__main__':
>
> # Running as a script, call the main function.
>
> objCustomer = Customer()
>
> objCustomer.CustomerName = "XYZ"
>
>
>
> objBank = Bank()
>
> objBank.lstCustomers.append(objCustomer)
>
>
>
>
>
>
>
> But this isn't how I would write it in Python. For starters, our naming
>
> conventions are different. Everything in Python is an object, even simple
>
> types like ints and strings, and even classes, so it isn't meaningful to
>
> prefix instances with "obj".
>
>
>
> We tend to avoid anything which even vaguely looks like Hungarian
>
> Notation, so "lstCustomer" is right out. Instead, we use plural for
>
> collections (lists, sets, dicts, whatever) of things, and singular for
>
> individual instances.
>
>
>
> Also, while we can use the "property" decorator to make computed
>
> attributes, we very rarely do just to enforce private/public variables.
>
> Our philosophy is, if you want to shoot yourself in the foot, we're not
>
> going to stop you. (People spend far too much time trying to work around
>
> private names in other languages for Python to spend too much effort in
>
> this area.) Instead, we have "private by convention": names starting with
>
> a single underscore are "private", so don't touch them, and if you do,
>
> you have nobody but yourself to blame when you shoot yourself in the foot.
>
>
>
> Similarly, the language doesn't spend much time enforcing type
>
> restrictions. Python is a dynamic language, and type restrictions go
>
> against that philosophy. If you have a good reason to put a non-string as
>
> the customer name, you can do so, but don't come crying to me if you
>
> break your code. So here is how I would write the above:
>
>
>
>
>
>
>
> class Bank:
>
> def __init__(self):
>
> self.customers = []
>
> self._micrcode = '' # Does this actually get used?
>
>
>
> class Customer:
>
> def __init__(self, name):
>
> # This type-check is optional.
>
> if not instance(name, str):
>
> raise TypeError('names must be strings')
>
> self.name = name
>
>
>
>
>
> if __name__ == '__main__':
>
> # Running as a script, call the main function.
>
> customer = Customer("XYX")
>
>
>
> bank = Bank()
>
> bank.customers.append(customer)
>
>
>
>
>
> The above is still not what I call professional quality -- no doc strings
>
> (documentation), and the bank doesn't actually do anything, but it's a
>
> start.
>
>
>
>
>
> --
>
> Steven
Thanks Steven for your Time and Effort. You have cleared many doubts and
concepts for that I was struggling, since I started learning python. But I am
falling in love for Python. Your explanation for private and public access
modifier was awesome as I w
Re: Correct Way to Write in Python
On Saturday, August 3, 2013 2:34:10 PM UTC+5:30, Peter Otten wrote: > Sagar Varule wrote: > > > > > On Saturday, August 3, 2013 12:17:49 PM UTC+5:30, Peter Otten wrote: > > >> [email protected] wrote: > > > > > Thanks a lot Peter. I appreciate your Help. You mentioned that C# code > > > above is not good. If you can point me why it is not good, would help me > > > learn new approaches as this type of Code I use to see long back(when i > > > was fresher). There may be better approaches or concepts i am not aware > > > of. If you can point me in that direction it would be gr8. > > > > As I said, I don't know C# -- but I already tried to fix some of the > > potential issues in my code snippet. > > > > - A list is not the best choice to store the customers -- there should be a > > lookup by some kind of ID (I picked the name to keep it simple) > > - Is it really necessary to expose that container in a language that > > provides "privacy"? > > - Is there ever a customer without name/ID? I'd say no, so these should be > > passed as constructor arguments. > > - Renaming a customer is a delicate process, you may need to keep track of > > the old name, the reason for the name, update your database etc., so I > > wouldn't allow setting the attribute and instead add a method > > > > Bank.rename_customer(...) > > > > or > > > > Bank.customers.rename_customer(...) > > > > Asking to translate code might make sense if you are a wizzard in the > > "other" language and want to see how a particular construct is written > > idomatically in Python, but to rewrite very basic C# code in Python is a bit > > like trying to learn a natural language by replacing one word after another > > in a text with the word in the new language that you looked up in a dict. > > The result tends to be underwhelming. > > > > I recommend that you read the tutorial and then try to solve a simple task > > in Python. Whenever you run into a problem you can come here for help. > > Because there's a real problem behind your code there will be different ways > > to solve it in Python, and you'll learn much more about the possibilites > > Python has to offer while your code gradually becomes more idiomatic. Thanks Peter for helping me out, Your Questions and suggestions are thoughts provoking and will help me every time I write a new Class. I will keep your suggestions. I am happy and amazed that Im getting help from strangers, But I got none when I approached programmers in my officeThanks a Lot...! -- http://mail.python.org/mailman/listinfo/python-list
Paramiko Help. Execute command to Interactive Shell which is opened by SSHClient()
Hi All, Im using Paramiko for my SSH automation. Im using method that is shown in demo_simple.py example which comes with Paramiko. Below is code from demo_simple.py. As you can make out, below code opens SSH connection and opens Interactie Shell, and then wait for the command from user. I want to submit the command to this Interactive Shell using code. try: client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.WarningPolicy()) print '*** Connecting...' client.connect(hostname, port, username, password) chan = client.invoke_shell() print repr(client.get_transport()) print '*** Here we go!' print interactive.interactive_shell(chan) chan.close() client.close() Well Another approach I tried is instead of opening interactive_shell, directly issue command using; stdin, stdout, stderr = client.exec_command(bv_cmd) for line in stderr.readlines(): print line for line in stdout.readlines(): print line But problem here is client.exec_command(bv_cmd) waits for command to execute completely and then it returns to stdout,stderr. And I want to see the ouput from the command during its execution. Because my command takes long time for execution. Big Picture in My Mind: Big Picture I that want to achieve is, Opening different SSH connection to different host, and it will issue commands to all host, wait for execution. All execution should happen parallel.(just wanted to share my thought, and wanted to hear opinions from you all. Is this possible??). I am not big programmer, just 2 years experience with asp.net C# 2.0 so i would appreciate if discussion happens in simple english. -- http://mail.python.org/mailman/listinfo/python-list
Re: [GUI] Good frameworks for Windows/Mac?
On Tuesday, August 6, 2013 4:05:40 PM UTC+5:30, Gilles wrote: > Hello > > > > I need to write a small GUI application that should run on Windows and > > Mac. > > > > What open-source framework would you recommend? I just need basic > > widgets (button, listbox, etc.) and would rather a solution that can > > get me up and running fast. > > > > I know about wxWidgets and Qt: Are there other good options I should > > know about? > > > > Thank you. Pyside is also Good. It has a Designer which can be helpful. -- http://mail.python.org/mailman/listinfo/python-list
Re: Paramiko Help. Execute command to Interactive Shell which is opened by SSHClient()
On Thursday, August 8, 2013 12:50:25 PM UTC+5:30, sagar varule wrote: > Hi All, > > > > Im using Paramiko for my SSH automation. Im using method that is shown in > demo_simple.py example which comes with Paramiko. Below is code from > demo_simple.py. > > > > As you can make out, below code opens SSH connection and opens Interactie > Shell, and then wait for the command from user. > > I want to submit the command to this Interactive Shell using code. > > > > try: > > client = paramiko.SSHClient() > > client.load_system_host_keys() > > client.set_missing_host_key_policy(paramiko.WarningPolicy()) > > print '*** Connecting...' > > client.connect(hostname, port, username, password) > > chan = client.invoke_shell() > > print repr(client.get_transport()) > > print '*** Here we go!' > > print > > interactive.interactive_shell(chan) > > chan.close() > > client.close() > > > > Well Another approach I tried is instead of opening interactive_shell, > directly issue command using; > > > > stdin, stdout, stderr = client.exec_command(bv_cmd) > > for line in stderr.readlines(): > > print line > > for line in stdout.readlines(): > > print line > > But problem here is client.exec_command(bv_cmd) waits for command to execute > completely and then it returns to stdout,stderr. And I want to see the ouput > from the command during its execution. Because my command takes long time for > execution. > > > > Big Picture in My Mind: Big Picture I that want to achieve is, Opening > different SSH connection to different host, and it will issue commands to all > host, wait for execution. All execution should happen parallel.(just wanted > to share my thought, and wanted to hear opinions from you all. Is this > possible??). I am not big programmer, just 2 years experience with asp.net C# > 2.0 so i would appreciate if discussion happens in simple english. Can any one comment on this.. -- http://mail.python.org/mailman/listinfo/python-list
Re: Paramiko Help. Execute command to Interactive Shell which is opened by SSHClient()
On Sunday, August 11, 2013 11:28:31 AM UTC+5:30, Joshua Landau wrote: > On 11 August 2013 06:18, sagar varule wrote: > > > Can any one comment on this.. > > > > If you don't get replies here it's probably because no-one knows > > Paramiko. I suggest posting elsewhere to see if there are any Paramiko > > users in other places willing to help. There might be a Paramiko > > mailing list. > > > > You also didn't say what didn't work with the first block of code. > > Also, what is "interactive"? Submitting Command to Interactive Shell through code did not work. -- http://mail.python.org/mailman/listinfo/python-list
Integration using scipy odeint
Dear all I'm using Python 3.4.3. I am facing a problem in integrating using odeint solver. In the following code, tran is a function and in those are the variables which are arrays. These variables change their values with respect to time (the time which I pass to the function). I tried defining a loop inside the function, but Python throws an error saying float object not iterable. Please guide me how to solve this problem. #initial is an array containing initial values for the integration, dt is the time array with unequal time steps, which I have captured from other part of the code def tran(initial,dt): for i in dt: k1 [i] = 2.8e8 * math.exp(-21100/ta[i]) # k1,k2,k3 & k4 are constants which change according to temperature (ta), which in turn changes with respect to time. k2 [i] = 1.4e2 * math.exp(-12100/ta[i]) # ta changes its values according to dt, which is array. It runs from 0-6 with unequal time steps. k3 [i] = 1.4e5 * ta[i] * math.exp(-19680/ta[i]) # I've captured dt and all other arrays here from another loop, which is not of importtance. k4 [i] = 1.484e3 * ta[i] y = initial[0] z = initial[1] dn = (6*rho*initial[1]) dd = (math.pi*2000*initial[0]) ds = (dn/dd)**1/3 dydt = (166.2072*ta[i]*cca[i] - (1.447e13 * ta[i]**0.5 * rho**1/6 * y**1/6 * rho**1/6 * z**1/6 * 0.0832)) # cca,ta are arrays. y & z are 2 dependent variables dzdt = (k1[i]*ta[i]*cca[i]*12.011 + (21.2834*k2[i]*ta[i]*cca[i] * y**1/2 *ds) - (k3[i]*ta[i]*12.011*y*math.pi*ds**2 * cco[i]) - (phi*k4[i]*ta[i]*xo[i]*12.011*y*math.pi*ds**2)) return [dydt,dzdt] # dydt & dzdt are my final time integrated values initial = [0.01,1e-5] sol = odeint(tran, initial, dt) #this is my function call If I pass array in my function call, it says only length-1 can be converted to Python scalars. So I request all the experts in the group to tell me where I'm going wrong. Regards -- https://mail.python.org/mailman/listinfo/python-list
failure in installing
hey, there is a failure installing python3.5.0 in my PC can u help -- https://mail.python.org/mailman/listinfo/python-list
Need help in pulling SQL query out of log file...
Hi,
I have a log file which has lot of information like..SQL query.. number of
records read...records loaded etc..
My requirement is i would like to read the SQL query completly and write it to
another txt file.. also the log file may not be always same so can not make
static choices...
my logfile is like below :
*LOg file starts**
Fri Aug 08 16:00:04 2014 : WRITER_1_*_1> WRT_8005 Writer run started.
Fri Aug 08 16:00:04 2014 : READER_1_2_1> BLKR_16007 Reader run started.
Fri Aug 08 16:00:04 2014 : WRITER_1_*_1> WRT_8158
*START LOAD SESSION*
Load Start Time: Fri Aug 08 16:00:04 2014
Target tables:
EIS_REQUEST_LOG_26MAYBKP
T_delta_parm_file
Fri Aug 08 16:00:04 2014 : READER_1_2_1> RR_4010 SQ instance
[SQ_Shortcut_to_EIS_REQUEST_LOG] SQL Query [SELECT
EIS_REQUEST_LOG_26MAYBKP.RqstId, EIS_REQUEST_LOG_26MAYBKP.RQSTLoadStatCd FROM
EIS_REQUEST_LOG_26MAYBKP]
Fri Aug 08 16:00:04 2014 : READER_1_2_1> RR_4049 RR_4049 SQL Query issued to
database : (Fri Aug 08 16:00:04 2014)
Fri Aug 08 16:00:04 2014 : READER_1_2_1> RR_4035 SQL Error [
FnName: Prepare -- [Teradata][ODBC Teradata Driver][Teradata Database] Object
'EIS_REQUEST_LOG_26MAYBKP' does not exist. ].
Fri Aug 08 16:00:04 2014 : READER_1_2_1> BLKR_16004 ERROR: Prepare failed.
Fri Aug 08 16:00:04 2014 : READER_1_1_1> RR_4029 SQ Instance [SQ_RSTS_Tables]
User specified SQL Query [--- Approved By ICC Team---
---SELECT A.LOGSYS ,
---D."/BIC/NIGNRCSYS" ,
---B.ODSNAME ,
---C.ODSNAME_TECH ,
---C.PARTNO ,
---C.REQUEST ,
---E.SID
---FROM
---sapbzd."RSISOSMAP" A,
---sapbzd."RSTSODS" B,
---sapbzd."RSTSODSPART" C,
---sapbzd."/BIC/PNIGNRCSYS" D,
---sapbzd."/BI0/SREQUID" E,
---sapbzd."RSMONMESS"F
---WHERE A.OLTPSOURCE =
('ZNK_SHP_DDLN_CREATE_BE','ZNK_KNVP2_BD','ZNK_ZVBW_RTN_ORD_ITM_BN','2LIS_02_SCL_BE','ZNK_FX_CRCY_HIS_BE','ZNK_PO_FX_CALC_LOG_BD','2LIS_12_VCHDR_BE','2LIS_02_HDR_BN','ZNK_SHP_DDLN_CHANGE_BD','1_CO_PAGL11000N1_BE','0CUSTOMER_ATTR_BE','2LIS_08TRTLP_BD','2LIS_02_SCN_BD','2LIS_02_HDR_BD','2LIS_13_VDITM_BE','0CO_OM_CCA_9_BE','ZNK_SO_BDSI_OPNDMD_BE','2LIS_11_VAHDR_BE','ZNK_ZVBW_MBEW_BE','2LIS_13_VDHDR_BN','ZNK_SHP_DDLN_CHANGE_BE','NK_ADDR_NUMBR_BN','0CUSTOMER_TEXT_BE','6DB_J_3ABD_DELTA_AFFL_AD','0MAT_PLANT_ATTR_BE','ZNK_BDCPV_BD','1_CO_PAGL11000N1_BD','2LIS_11_VASTI_BD','ZNK_ZVBW_MSKU_BE','ZNK_SHP_DDLN_CREATE_BD','0SCEM_1_BC','2LIS_11_VAHDR_BD','2LIS_11_VASCL_BD','0MATERIAL_TEXT_BE','0MATERIAL_ATTR_BE','ZNK_BDCPV_BE','2LIS_02_ITM_BN','2LIS_11_VASCL_BE','2LIS_11_VAITM_BN','NK_ADDR_NUMBR_BE','2LIS_08TRTK_BE','ZNK_SD_LIKPPS_BN','2LIS_03_BF_BE','ZNK_SO_BDBS_ALLOC_BD','ZNK_TD_3AVASSO_BN','0EC_PCA_3_BD','ZNK_TD_3AVAP_BE','2LIS_11_VAITM_BE','0CUST_SALES_ATTR_BN','0EC_PCA_3_
BE','2LIS_13_VDITM_BN','2LIS_11_VASTH_BD','2LIS_13_VDITM_BD','0CUST_SALES_ATTR_BD','ZNK_TD_3AVASSO_BD','2LIS_02_SCN_BE','2LIS_08TRTS_BD','0CUSTOMER_ATTR_BN','ZNK_TD_3AVASSO_BE','ZNK_ZVBW_MSLB_BE','ZNK_TD_3AVAP_BD','0CUSTOMER_TEXT_BN','6DB_J_3ABD_DELTA_US_AD','0CUSTOMER_TEXT_BD','2LIS_11_VAHDR_BN','ZNK_SO_BDBS_ALLOC_BN','0GL_ACCOUNT_TEXT_BE','0GL_ACCOUNT_TEXT_BD','2LIS_11_VAITM_BD','ZNK_TD_3AVATL_BE','ZNK_SO_BDBS_ALLOC_BE','ZNK_EBAN_BE','ZNK_SO_BDSI_OPNDMD_BN','ZNK_SD_LIKPPS_BD','ZNK_ZVBW_RTN_ORD_ITM_BE','2LIS_08TRTS_BN','2LIS_02_HDR_BE','ZNK_TD_3AVATL_BD','ZNK_VBPA_BE','ZNK_FX_CRCY_HIS_BD','2LIS_13_VDHDR_BE','NK_ADDR_NUMBR_BD','2LIS_12_VCITM_BD','2LIS_08TRTK_BD','2LIS_11_VASCL_BN','ZNK_ZVBW_MCHB_BE','6DB_J_3ABD_SCL_DELTA_AP_AE','ZNK_SO_BDSI_OPNDMD_BD','ZNK_KNVP2_BE','0MAT_SALES_ATTR_BE','ZNK_TD_3AVAP_BN','2LIS_13_VDHDR_BD','0GL_ACCOUNT_ATTR_BD','2LIS_02_SCL_BD','ZNK_VBPA_BD','2LIS_02_ITM_BD','ZNK_TD_3AVATL_BN','ZNK_ZVBW_RTN_ORD_ITM_BD','ZNK_PO_FX_CALC_LOG_BE','6DB_J_3ABD_DELTA_EMEA_
AD','0GL_ACCOUNT_ATTR_BE','2LIS_03_BF_BD','2!
LIS_11_V
ASTI_BE','0CO_OM_CCA_9_BD','0CUST_SALES_ATTR_BE','2LIS_12_VCITM_BE','0CUSTOMER_ATTR_BD','2LIS_02_ITM_BE','2LIS_08TRTLP_BE','2LIS_12_VCHDR_BD','ZNK_EBAN_BD','2LIS_08TRTS_BE','2LIS_02_SCL_BN','2LIS_11_VASTH_BE','ZNK_SD_LIKPPS_BE')
---AND A.LOGSYS = D."/BIC/NKLOGSYST"
---AND A.OBJVERS = 'A'
---AND A.TRANSTRU = B.ODSNAME
---AND B.DATETO = 0101
---AND B.OBJSTAT = 'ACT'
---AND B.ODSNAME_TECH = C.ODSNAME_TECH
---AND C.DELFLAG <> 'X'
---AND D."/BIC/NIGNRCSYS" = ('R3_PRA','R3_PRD','R3_PRF','EM_EMP')
---AND D.OBJVERS = 'A'
---AND E.REQUID = C.REQUEST
---AND F.RNR = C.REQUEST
---AND F.MSGNO = '344'
---AND F.AUFRUFER = '09'---
SELECT A.LOGSYS ,
D."/BIC/NIGNRCSYS" ,
B.ODSNAME ,
C.ODSNAME_TECH ,
C.PARTNO ,
C.REQUEST ,
E.SID
FROM
sapbzd."RSISOSMAP" A,
sapbzd."RSTSODS" B,
sapbzd."RSTSODSPART" C,
sapbzd."/BIC/PNIGNRCSYS" D,
sapbzd."/BI0/SREQUID" E,
sapbzd."RSMONMESS"F
WHERE
A.OLTPSOURCE in
('ZNK_SHP_DDLN_CREATE_BE','ZNK_KNVP2_BD','ZNK_ZVBW_RTN_ORD_ITM_BN','2LIS_02_SCL_BE','ZNK_FX_CRCY_HIS_BE','ZNK_PO_FX_CALC_LOG_BD','2LIS_12_VCHDR_BE','2LIS_02_HDR_BN','ZNK_SHP_DDLN_CHANGE_BD','1_CO_PAGL11000N1_BE','0CUSTOMER_ATTR_BE','2LIS_08TRTLP_BD','2LIS_02_SCN_BD','2LIS_02_HDR_BD','2LIS_13_VDITM
Re: Need help in pulling SQL query out of log file...
On Monday, 13 October 2014 22:40:07 UTC-7, alex23 wrote:
> On 14/10/2014 11:47 AM, Sagar Deshmukh wrote:
>
> > I have a log file which has lot of information like..SQL query.. number of
> > records read...records loaded etc..
>
> > My requirement is i would like to read the SQL query completly and write it
> > to another txt file..
>
>
>
> Generally we encourage people to post what they've tried to the list. It
>
> helps us identify what you know and what you need help with.
>
>
>
> However, given:
>
>
>
> > the log file may not be always same so can not make static choices...
>
>
>
> You'll probably want to use regular expressions:
>
>
>
> https://docs.python.org/howto/regex.html
>
>
>
> Regexps let you search through the text for known patterns and extract
>
> any that match. To extract all SQL query sections, you'll need to come
>
> up with a way of uniquely identifying them from all other sections.
>
> Looking at your example log file, it looks like they're all of the format:
>
>
>
> SQL Query []
>
>
>
> From that we can determine that all SQL queries are prefixed by 'SQL
>
> Query [' and suffixed by ']', so the content you want is everything
>
> between those markers. So a possible regular expression might be:
>
>
>
> SQL Query \[(.*?)\]
>
>
>
> To quickly explain this:
>
>
>
> 1. "SQL Query " matches on that string
>
> 2. Because [] have meaning for regexes, to match on literal
>
> brackets you need to escape them via \[ and \]
>
> 3. ( ) is a group, whats contained in here will be returned
>
> 4. .* means to grab all matching text
>
> 5. ? means to do an "ungreedy" grab ie it'll stop at the first \]
>
> it encounters.
>
>
>
> Pulling the queries out of your log file should be as simple as:
>
>
>
> import re
>
>
>
> log = open('logfile').read()
>
> queries = re.findall("SQL Query \[(.*?)\]", log, re.DOTALL)
>
>
>
> Because the queries can fall across multiple lines, the re.DOTALL flag
>
> is required to treat EOL markers as characters.
>
>
>
> Hope this helps.
Hi,
This helps and its working... Thank you so much
--
https://mail.python.org/mailman/listinfo/python-list
help regarding re.search
Hi, I have a small program where I want to do just a small regex operation. I want to see if value of a variable 'A' is present in an another variable 'B'. The below code works fine but as soon as the variable 'A' has some string including a dot it fails. for example say: B="dpkg.ipaz The code works fine when A="dpkg" however the code does not work when A="dpkg.ipa" if re.search(A,B): # do something. Can somebody please help me ? -- http://mail.python.org/mailman/listinfo/python-list
help regarding re.search
Hi, I have a small program where I want to do just a small regex operation. I want to see if value of a variable 'A' is present in an another variable 'B'. The below code works fine but as soon as the variable 'A' has some string including a dot it fails. for example say: B="dpkg.ipaz The code works fine when A="dpkg" however the code does not work when A="dpkg.ipa" if re.search(A,B): # do something. Can somebody please help me ? -- http://mail.python.org/mailman/listinfo/python-list
Re: help regarding re.search
If A in B: does nt seem to be working. Am I missing something here. -$agar On Sep 15, 2011 7:25 AM, "Chris Rebert" wrote: > On Wed, Sep 14, 2011 at 6:41 PM, Sagar Neve wrote: >> Hi, >> I have a small program where I want to do just a small regex operation. >> I want to see if value of a variable 'A' is present in an another variable >> 'B'. The below code works fine but as soon as the variable 'A' has some >> string including a dot it fails. > > There's no need to use regexes at all! Just do: > if A in B: > # do something > >> for example say: >> B="dpkg.ipaz >> The code works fine when A="dpkg" >> however the code does not work when A="dpkg.ipa" > > Right, because period is a regex metacharacter. To have it treated as > a literal character to match, escape it: > http://docs.python.org/library/re.html#re.escape > > Cheers, > Chris > -- > http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: help regarding re.search
Here is the code url="http://xy.yz.com/us/r1000/012/Purple/b1/c6/e2/mzm.dxkjsfbl..d2.dpkg.ipa " Man_Param="/us/r1000" Opt_Param1="Purple" Opt_Param2="dpkg.ipa" if (Opt_Param2 in url): print "hello." else: print "bye." It gives me: ./sample.py: line 9: syntax error near unexpected token `:' ./sample.py: line 9: `if (Opt_Param2 in url):' Help. On Thu, Sep 15, 2011 at 9:05 AM, Chris Rebert wrote: > On Wed, Sep 14, 2011 at 8:33 PM, Sagar Neve wrote: > > If A in B: > > does nt seem to be working. > > Am I missing something here. > > Please provide a snippet of the code in question, and be specific > about how it's not working. > > Cheers, > Chris > -- > http://rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: help regarding re.search
I figured it out with the sample program I gave you. It was my mistake;
However, the same thing with same values is not working in my main program.
Here is what I am trying: The program traverses with correct values upto the
if condition we just discussed; but fails to quality that if condition;
instead it should qualify.
for key in dictionary:
m=re.search(key, url)
if m !=None:
values=dictionary[key]
for v in values:
v_array=v.split(',')
Man_Param=v_array[4]
Opt_Param1=v_array[5]
Opt_Param2=v_array[6]
Cat=v_array[1]
Man_Param=re.sub(r'"(?P.*?)"','\g', Man_Param)
Opt_Param1=re.sub(r'"(?P.*?)"','\g', Opt_Param1)
Opt_Param2=re.sub(r'"(?P.*?)"','\g', Opt_Param2)
Cat=re.sub(r'"(?P.*?)"','\g', Cat)
Cat=re.sub(r':','_', Cat)
Cat=re.sub(r' ','_', Cat)
print "hello..Man_Param=%s,Opt_Param1=%s,
Opt_Param2=%s\n" %(Man_Param,Opt_Param1,Opt_Param2)
#sys.exit(1)
if len(Opt_Param1):
if len(Opt_Param2):
#if (re.search(Man_Param,url) and
re.search(Opt_Param1,url) and re.search(Opt_Param2,url) ):
print url
* if (Man_Param in url):#and (Opt_Param1 in url)
and (Opt_Param2 in url):*
print "all are found..\n"
sys.exit(1)
if((int(cl) < 5000 or int(rc) == 206) and
re.match(r"AS_D",Cat) ):
Cat= Cat + "_cont"
foutname = "output" + "/" + Cat +"." +
str(cnt)
fout =open(foutname, "a")
fout.write(line)
fout.close
else:
print "here\n";
sys.exit(1)
On Thu, Sep 15, 2011 at 10:19 AM, Chris Angelico wrote:
> On Thu, Sep 15, 2011 at 2:41 PM, Sagar Neve wrote:
> > ./sample.py: line 9: syntax error near unexpected token `:'
> > ./sample.py: line 9: `if (Opt_Param2 in url):'
> >
>
> It worked for me in Python 3.2. What version of Python are you using?
>
> ChrisA
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: help regarding re.search
Yes. It is been resolved now for the sample program. however, as mentioned in other post. It is not working in the main program On Thu, Sep 15, 2011 at 10:25 AM, Kushal Kumaran < [email protected]> wrote: > On Thu, Sep 15, 2011 at 10:11 AM, Sagar Neve wrote: > > Here is the code > > > > > > url=" > http://xy.yz.com/us/r1000/012/Purple/b1/c6/e2/mzm.dxkjsfbl..d2.dpkg.ipa"; > > > > Man_Param="/us/r1000" > > Opt_Param1="Purple" > > Opt_Param2="dpkg.ipa" > > > > if (Opt_Param2 in url): > > print "hello." > > else: > > print "bye." > > > > It gives me: > > > > ./sample.py: line 9: syntax error near unexpected token `:' > > ./sample.py: line 9: `if (Opt_Param2 in url):' > > > > > > That looks like a bash error message. Syntax errors in python show up > with a stack trace. Run your program using the python interpreter > like this: > > python file.py > OR > python3 file.py > > whatever is applicable in your environment. > > > > > > > On Thu, Sep 15, 2011 at 9:05 AM, Chris Rebert wrote: > >> > >> On Wed, Sep 14, 2011 at 8:33 PM, Sagar Neve > wrote: > >> > If A in B: > >> > does nt seem to be working. > >> > Am I missing something here. > >> > >> Please provide a snippet of the code in question, and be specific > >> about how it's not working. > >> > > -- > regards, > kushal > -- http://mail.python.org/mailman/listinfo/python-list
Re: help regarding re.search
Hey Thanks. I just resolved it and yes you are right there was a (hidden) new-line to it. I found it in a crude way of putting dots before and after. I was to post about it here and saw your message. I was not knowing about %r. Thanks for that. Thats a good addition to my knowledge. Thanks a bunch of all. My day is saved. Best Regards, Sagar Neve. On Thu, Sep 15, 2011 at 2:35 PM, Gelonida N wrote: > Hi Sagar, > > In order to be able to help you I propose following: > > On 09/15/2011 06:54 AM, Sagar Neve wrote: > . . . > > print "hello..Man_Param=%s,Opt_Param1=%s, > > Opt_Param2=%s\n" %(Man_Param,Opt_Param1,Opt_Param2) > > Change above line into > > > print "hello..Man_Param=%r,Opt_Param1=%r, > > Opt_Param2=%r\n" %(Man_Param,Opt_Param1,Opt_Param2) > > > and show us the output of an example which is NOT working. > > printing with '%r" might help to show some 'hidden special characters' > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Please solve me the problem
Hi I am sagar. I want to write a python script that will run the python scripts automatically from a directory. Please help me out to sovle this problem? -- with regards Mr. Sagar Panda Mob:9986142755 -- http://mail.python.org/mailman/listinfo/python-list
Re: assigning multi-line strings to variables
Use triple quote: d = """ this is a sample text which does not mean anything""" "goldtech" wrote in message news:4e25733e-eafa-477b-a84d-a64d139f7...@u34g2000yqu.googlegroups.com... On Apr 27, 7:31 pm, Brendan Abel <[email protected]> wrote: > On Apr 27, 7:20 pm, goldtech wrote: > > > Hi, > > > This is undoubtedly a newbie question. How doI assign variables > > multiline strings? If I try this i get what's cited below. Thanks. > > > >>> d="d > > d" > > >>> d > > > Traceback (most recent call last): > > File "", line 1, in > > NameError: name 'd' is not defined > > d = "d"\ > "d" > > or > > d = "dd\ > dd" > > You don't need the trailing slash in the first example if you are > writing this in a script, python assumes it. Thanks but what if the string is 500 lines. Seems it would be hard to put a "\" manually at the end of every line. How could i do that? -- http://mail.python.org/mailman/listinfo/python-list
Expect Telnet
Hi all,
I am not sure how this works, but am composing my query here.
I am trying to expect the below snippet using telnetlib.
#
bash# install
blah blah blah
do you want to continue [y/n]? y
blah blah blah
blah blah blah
blah blah blah
blah blah blah
Installation complete
bash#
##
For the above, i am doing
t.read_until("bash#")
t.write("install\n")
t.read_until("n]? ")
t.write("y\n")
t.read_until("bash#")
t.write('exit\n")
However, from the time i key 'y/n' till the install script exits, there is a
lot of data that is to be logged. I takes around 1 hour for the whole script
to exit.
Is there some way i can read whats happening behind the scenes until it hits
the read_until?
Thanks for the help
--
Vinay
--
http://mail.python.org/mailman/listinfo/python-list
buggy popup
Hi All, Need some idea here: On my windows machine, there is a Java based program that runs all the time. Every now and then, a popup appears out of this program. To close this popup, it requires user to Check the Do-not-show-this-popup check box and then, click on OKAY button. Is there a python way of automating the above procedure? Say, I run a python script on my windows machine which waits all the time and then if the popup appears, the python guy checks the check box and then hits the OKAY button? Any modules/ packages that I can refer to? A small hint would be of a big help. Thanks, -- Vinay -- http://mail.python.org/mailman/listinfo/python-list
