Convert int to string in python


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert int to string in python
# 8  
Old 01-07-2014
HI all,

I solved the problem in a different

Code:
from collections import defaultdict
import sys

d = defaultdict(list)

with open (sys.argv[1]) as f:
        for line in f:
                line_data = line.strip().split()
                d[' '.join(line_data[0:5])].append(line_data[5])

for k in sorted(d.keys(), key = lambda s: (s.split()[0], int(s.split()[1]))):
        print(k,  ', '.join(d[k]))


Last edited by Scott; 01-07-2014 at 07:58 AM.. Reason: Use CODE tags, please, not ICODE tags for multi-line code snippets
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Splitting string and storing in int

I have a string containing 2 integers separated by /, for example 12/8 or 8/6 am want to store the numbers in two integers. (3 Replies)
Discussion started by: kristinu
3 Replies

2. Programming

IPv4 string->int

Does anyone know how to convert a IP address given as 'string' into a 'u_int32_t'? Are there any build any functions already? (1 Reply)
Discussion started by: Freaky123
1 Replies

3. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

4. Programming

How to pass int and return string in C?

hi I want to write a function which takes int as input and returns a string like this. char GetString(int iNo) { switch(iNo) { case 0: return "Zero"; break; case 1: return "One"; break; } } void main() { int i; printf("Enter... (1 Reply)
Discussion started by: atharalikhan
1 Replies

5. Programming

Handle int listen(int sockfd, int backlog) in TCP

Hi, from the manual listen(2): listen for connections on socket - Linux man page It has a parameter called backlog and it limits the maximum length of queue of pending list. If I set backlog to 128, is it means no more than 128 packets can be handled by server? If I have three... (3 Replies)
Discussion started by: sehang
3 Replies

6. Shell Programming and Scripting

From string to int ?

hello guys i m new to shell scripting and can't find out why this structure is not right I m guessing this happens because $LINESUM is a string . so how can i do this ? i want my script to do so many loops as the number of the lines of one custom file. #!/bin/bash echo give me path name... (5 Replies)
Discussion started by: xamxam
5 Replies

7. Shell Programming and Scripting

Compare string output to int value?

Hi, i'd like to implmeent emergency shutdown script in case our AC dies and the temperature rises too high. I can get core temperatures with: sensors | grep Core | cut -c15-16 Result is: 23 18 18 13 21 18 15 17 How can I check if any of the cores is above eg. 80 (that's C of... (2 Replies)
Discussion started by: zapp0
2 Replies

8. Solaris

Convert DWORD to int on solaris for 64-bit

i am converting application from 32-bit to 64-bit on Solaris. How can I convert "DWORD" on Solaris 64-bit to int. Thanks. (1 Reply)
Discussion started by: amit_27
1 Replies

9. Programming

to convert int to hex

Hi, Can you help me in converting int value to hex in a single command. Thanks (8 Replies)
Discussion started by: naan
8 Replies

10. Shell Programming and Scripting

how to convert a string to int

Hi, i want to read a text file whose content(single line) will be a number like 1 or 2 or 3 ..... what i want to do is to read the file and increment the content of the file, using unix scripting. Regards, Senthil Kumar Siddhan. (2 Replies)
Discussion started by: senthilk615
2 Replies
Login or Register to Ask a Question
Mail::Message::Convert::HtmlFormatText(3pm)		User Contributed Perl Documentation	       Mail::Message::Convert::HtmlFormatText(3pm)

NAME
Mail::Message::Convert::HtmlFormatText - Convert HTML into Text INHERITANCE
Mail::Message::Convert::HtmlFormatText is a Mail::Message::Convert is a Mail::Reporter SYNOPSIS
use Mail::Message::Convert::HtmlFormatText; my $af = Mail::Message::Convert::HtmlFormatText->new; my $plain_body = $af->format($body); DESCRIPTION
Convert HTML/XHTML message body objects into plain text bodies using HTML::FormatText. This package requires HTML::TreeBuilder and HTML::FormatText which are not installed by default together with Mail::Box. See also Mail::Message::rebuild() with rule "text_alternative_for_html". Converters between message objects Other converters METHODS
Constructors Mail::Message::Convert::HtmlFormatText->new(OPTIONS) -Option --Defined in --Default fields Mail::Message::Convert <see description> leftmargin 3 log Mail::Reporter 'WARNINGS' rightmargin 72 trace Mail::Reporter 'WARNINGS' fields => NAMES|ARRAY-OF-NAMES|REGEXS leftmargin => INTEGER The column of the left margin, passed to the formatter. log => LEVEL rightmargin => INTEGER The column of the right margin, passed to the formatter. trace => LEVEL Converting $obj->format(BODY) Pass an html/xhtml encoded body, and a plain text body is returned. Characters are translated into Latin1. $obj->selectedFields(HEAD) See "Converting" in Mail::Message::Convert Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Message::Convert::HtmlFormatText->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Message::Convert::HtmlFormatText->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Message::Convert::HtmlFormatText->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Message::Convert::HtmlFormatText(3pm)