Sponsored Content
Top Forums Shell Programming and Scripting Concatenate lines in a single paragraph Post 302316827 by ghostdog74 on Saturday 16th of May 2009 07:57:25 PM
Old 05-16-2009
if you have Python
Code:
d={}
for line in open("file"):
    line=line.strip().split(":")
    d[line[0].strip()]=line[-1].strip()
for k in d.keys():    
    if "User profile" in k: 
        user=k
        break    
print "In date %s, %s. This is a warning from %s." %(d['Date'],d['Time'],user)

output
Code:
# ./test.py
In date 9/10/2008, 50 PM. This is a warning from User profile MyComp-KKL(S-1-5-21-3230802392-3390281410-1560515013-1307)..

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a paragraph to single line

I need to check the count of pipes on each line of the data to make sure we 4 pipes if its less i need to keep adding the string to form a single line ( Need to join/ concat the below lines until i get the 4 pipes which is end of record ). This fields is basicall a memo where the user would have... (6 Replies)
Discussion started by: rimss
6 Replies

2. UNIX Desktop Questions & Answers

How to concatenate consecutive lines

I have a few lines like -- feature 1, subfeat 0, type 3, subtype 1, value 0, -- feature 1, subfeat 0, type 1, subtype 1, value 0, I would like to concatenate the... (1 Reply)
Discussion started by: shivi707
1 Replies

3. Shell Programming and Scripting

Concatenate two lines in one

Does anyone know a way I can fix my file below where it has lines that are cut? Just like the (notice the space before ms,c=PH).. dn: cn=english,ou=Messaging,ou=lang,o=subject,t=j ms,c=PH which should be dn: cn=english,ou=Messaging,ou=lang,o=subject,t=jms,c=PH The whole text file... (5 Replies)
Discussion started by: Orbix
5 Replies

4. Shell Programming and Scripting

concatenate lines in pairs

Hi, I have a text file with the following contents /C=IT/O=INFN/OU=Personal Certificate/L=Napoli/CN=Some guy /C=IT/O=INFN/CN=INFN CA /O=Grid/O=NorduGrid/OU=uninett.no/CN=Another guy /O=Grid/O=NorduGrid/CN=NorduGrid Certification Authority /C=TW/O=AP/OU=GRID/CN=Someone else... (5 Replies)
Discussion started by: kerl
5 Replies

5. Shell Programming and Scripting

Concatenate lines between lines starting with a specific pattern

Hi, I have a file such as: --- >contig00001 length=35524 numreads=2944 gACGCCGCGCGCCGCGGCCAGGGCTGGCCCA CAGGCCGCGCGGCGTCGGCTGGCTGAG >contig00002 length=4242 numreads=43423 ATGCCGAAGGTCCGCCTGGGGCTGG CGCCGGGAGCATGTAGCG --- I would like to concatenate the lines not starting with ">"... (9 Replies)
Discussion started by: s052866
9 Replies

6. Shell Programming and Scripting

How to search for multiple lines and put them into one paragraph?

Dear all, I'm trying to manipulate a data file and putting a certain lines into one paragraph. What am I actually want to do is that search some lines in a data file. These lines begin with "1\1\GINC-" and end with "\\@" or the following two empty lines as shown in blue. A part of the text... (11 Replies)
Discussion started by: liuzhencc
11 Replies

7. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

8. Programming

Concatenate two lines in a fIle

Hi All, Can any one help me in finding the solution for concatenating two or more lines in a file and writing them to a temporary file. for Example: He is a wise student. So he got first rank. This is in a file i want the output as He is a wise student so he got first rank. into a file... (3 Replies)
Discussion started by: uday.sena.m
3 Replies

9. UNIX for Dummies Questions & Answers

Concatenate three lines into one

Hi. I'm new to this forum. I am attempting to parse an Audit Log from Cognos/TM1, selecting only Event IDs of "client" which are found on the "start-tag" record. These Logs are in a pseudo-XML format but not a true XML format. I want to FTP an Audit Log File from the Cognos server to our UNIX... (7 Replies)
Discussion started by: FredAtArrow
7 Replies

10. Shell Programming and Scripting

Join Lines every paragraph in a file.txt

Hi all, Is there any idea on how to automate convert the paragraph in one line in a file, this will happen after OCR the documents, OCR split every paragraph. I need to join all the paragraph in one line. #cat file.txtThe Commission on Higher Education (CHED) was created through Republic Act... (7 Replies)
Discussion started by: lxdorney
7 Replies
PS_SHOW_BOXED(3)							 1							  PS_SHOW_BOXED(3)

ps_show_boxed - Output text in a box

SYNOPSIS
int ps_show_boxed (resource $psdoc, string $text, float $left, float $bottom, float $width, float $height, string $hmode, [string $feature]) DESCRIPTION
Outputs a text in a given box. The lower left corner of the box is at ($left, $bottom). Line breaks will be inserted where needed. Multi- ple spaces are treated as one. Tabulators are treated as spaces. The text will be hyphenated if the parameter $hyphenation is set to TRUE and the parameter $hyphendict contains a valid filename for a hyphenation file. The line spacing is taken from the value leading. Paragraphs can be separated by an empty line just like in TeX. If the value parindent is set to value > 0.0 then the first n lines will be indented. The number n of lines is set by the parameter numindent- lines. In order to prevent indenting of the first m paragraphs set the value parindentskip to a positive number. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $text - The text to be output into the given box. o $left - x-coordinate of the lower left corner of the box. o $bottom - y-coordinate of the lower left corner of the box. o $width - Width of the box. o $height - Height of the box. o $hmode - The parameter $hmode can be "justify", "fulljustify", "right", "left", or "center". The difference of "justify" and "fulljus- tify" just affects the last line of the box. In fulljustify mode the last line will be left and right justified unless this is also the last line of paragraph. In justify mode it will always be left justified. o $feature - USED PARAMETERS
The output of ps_show_boxed(3) can be configured with several parameters and values which must be set with either ps_set_parameter(3) or ps_set_value(3). Beside the parameters and values which affect text output, the following parameters and values are evaluated. o leading (value) -Distance between baselines of two consecutive lines. o linebreak (parameter) - Set to "true" if you want a carriage return to start a new line instead of treating it as a space. Defaults to "false". o parbreak (parameter) - Set to "true" if you want a carriage return on a single line to start a new paragraph instead of treating it as a space. Defaults to "true". o hyphenation (parameter) - Set to "true" in order to turn hyphenation on. This requires a dictionary to be set with the parameter "hyphendict". Defaults to "false". o hyphendict (parameter) - Filename of the dictionary used for hyphenation pattern (see below). o hyphenminchar (value) - The number of chars which must at least be left over before or after the hyphen. This implies that only words of at least two times this value will be hyphenated. The default value is three. Setting a value of zero will result in the default value. o parindent (value) - Set the amount of space in pixel for indenting the first m lines of a paragraph. m can be set with the value "numindentlines". o parskip (value) - Set the amount of extra space in pixel between paragraphs. Defaults to 0 which will result in a normal line distance. o numindentlines (value) - Number of lines from the start of the paragraph which will be indented. Defaults to 1. o parindentskip (value) - Number of paragraphs in the box whose first lines will not be indented. This defaults to 0. This is useful for paragraphs right after a section heading or text being continued in a second box. In both case one would set this to 1. o linenumbermode (parameter) - Set how lines are to be numbered. Possible values are "box" for numbering lines in the whole box or "paragraph" to number lines within each paragraph. o linenumberspace (value) - The space for the column left of the numbered line containing the line number. The line number will be right justified into this column. Defaults to 20. o linenumbersep (value) - The space between the column with line numbers and the line itself. Defaults to 5. HYPHENATION
Text is hyphenated if the parameter hyphenation is set to true and a valid hyphenation dictionary is set. pslib does not ship its own hyphenation dictionary but uses one from openoffice, scribus or koffice. You can find their dictionaries for different languages in one of the following directories if the software is installed: o /usr/share/apps/koffice/hyphdicts/ o /usr/lib/scribus/dicts/ o /usr/lib/openoffice/share/dict/ooo/ Currently scribus appears to have the most complete hyphenation dictionaries. RETURN VALUES
Number of characters that could not be written. SEE ALSO
ps_continue_text(3). PHP Documentation Group PS_SHOW_BOXED(3)
All times are GMT -4. The time now is 09:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy