Python - Scan for string


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Python - Scan for string
# 1  
Old 05-19-2008
Python - Scan for string

Hi
i have a variable 'reform' and store the lines like

reform= {
record
string(8) ID;
string(4) PRD;
date("YYMMDD", split = "800101") DateofManufact;
string(4) PRDC_MODULE_NUM;
string(1) END_OF_RECORD = "\n";
}

I need to search for the character "\n"in the above variable 'reform'.
if "\n" is available then i need to return boolean
i.e

return not "\n" in fields

I tried like below

fields = $reform_out2.field_names()
return not "newline" in fields

It is not working, can any one throw some light into it.

Regards
Dhana
# 2  
Old 05-19-2008
Could you clarify it a bit? You're using curly braces, which indicate a dictionary, but you're not entering dictionary values. The code you provide doesn't execute in Python.

If you provide some working code that's giving bad results I'll try to help you fix it, but I can't do much with what you provided.

Thanks,
Shawn
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue Spliting String in Python

I have a string like below Note: I have have a single to any number of comma "," seperated string assigned to jdbc_trgt variable. I need to split jdbc_trgt using comma(,) as the delimiter. I tried the below but it fails as i dont know how can i read each split string iterately. for... (4 Replies)
Discussion started by: mohtashims
4 Replies

2. Shell Programming and Scripting

Python replace string

Hi, I have a python variable with a value like this : string = "abc.de.fghijk.com:zyz.ab.fgfijk.com:abc.ef.fghijk.com" They are hostnames separated by the special character ":" . From this string I want to make a list with values : (2 Replies)
Discussion started by: ctrld
2 Replies

3. Shell Programming and Scripting

Convert int to string in python

Hi, I have column 5 in a file which contains string like this for ex. RP11-125O5.2 SLCO1B1 CAPN1 FRMPD2 TXNL4B So I do by data = )] ValueError: invalid literal for int() with base 10: 'R' Can someday tell me how to convert this column into int successfully. Thank You in... (7 Replies)
Discussion started by: rossi
7 Replies

4. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

5. Programming

Python pickle.loads(string)

Will this sentence return the decode of the string? Why I put a string in it but the system say: invaild load key (1 Reply)
Discussion started by: Henryyy
1 Replies

6. Shell Programming and Scripting

[python]string to list conversion

I have a file command.txt. It's content are as follows:- The content of file is actually a command with script name and respective arguments. arg1 and arg2 are dummy arguments , format : -arg arg_value test is a argument specifying run mode , format : -arg In my python code, i read it and... (1 Reply)
Discussion started by: animesharma
1 Replies

7. Shell Programming and Scripting

python - string encoding error

I'm trying to pull a google calendar (successful) and then put the contents into a mysql db (almost successful). On one of the field I keep getting an encode error: #!/usr/bin/python from xml.etree import ElementTree import gdata.calendar.data import gdata.calendar.client import... (12 Replies)
Discussion started by: unclecameron
12 Replies

8. Programming

I need to scan my 'vector<string> mystrings' for duplicate entries.

Basically I'm trying to avoid writing paragraphs to do it. It is possible I could convert over to a vector<int>'s if that may help. Does anyone know how to do this without really turning it into a huge brainbuster? I have considered using a for() loop but I wasn't able to put anything into practice... (1 Reply)
Discussion started by: sepoto
1 Replies

9. Shell Programming and Scripting

Python String <--> Number

My question is so simple: A = raw_input("A ") if A == '56': VAR = (A + 54)/13 else: print "other operations" if I write in input 5656565656 i want to make some arithmetic operations if the first input is 56XXX but the output is TypeError: cannot concatenate 'str' and... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

10. Shell Programming and Scripting

python and string.find

Hi all, I'm not sure if this is the right forum, but i'll give it a try. Here is my problem: i have two files having basically the same things in it (hostnames): File 1 mituap01 mituap02 mituap03 File 2: mituap01 mituap04 mituap05 my goal is to get a .py out to check if pcs' in... (0 Replies)
Discussion started by: penguin-friend
0 Replies
Login or Register to Ask a Question