Sponsored Content
Top Forums Shell Programming and Scripting How to convert a column to last five digits Post 302357430 by grossgermany on Tuesday 29th of September 2009 09:27:26 PM
Old 09-29-2009
How to convert a column to last five digits

Hi

Suppose I have a input.csv file like this

Fort, 2034440-3333
Honda, b293489289
Toyota, 23423000


How to convert the second column to the following format, there are only two cases:
a.if the last five character is a hyphen plus four numeric digit, keep the the last five digits before the hypen as well as everything after hyphen (including hyphen).
b. if the last five character doesn't contain a hyphen, keep the last five digits.

so the output.csv is:

Fort, 34440-3333
Honda, 89289
Toyota, 23000

Thanks, I guess this will be done in awk but I have no idea how to do it.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Convert first line into column

I have a file: 2009_11 3455 500 5355 600 7777 700 The first line is the period. I want to concatenate the Period into every line using a one line command..I guess maybe awk or something. So the output would look like this: 3455 500 2009_11 5355 600 2009_11 7777 700 2009_11 ... (4 Replies)
Discussion started by: alfredo123
4 Replies

2. Shell Programming and Scripting

help: single digits inflated to 2 digits

Hi Folks Probably an easy one here but how do I get a sequence to get used as mentioned. For example in the following I want to automatically create files that have a 2 digit number at the end of their names: m@pyhead:~$ for x in $(seq 00 10); do touch file_$x; done m@pyhead:~$ ls file*... (2 Replies)
Discussion started by: amadain
2 Replies

3. Shell Programming and Scripting

Convert string in a column

Hi I got this: aix.acct,aix.system.config.cron,aix.system.config.src,aix.system.install,string2 and I want this: aix.acct system.config.cron aix.system.config.src aix.system.install string2 I tried using sed by changing ',' into an 'ENTER' but I couldn't. :-( thxs (2 Replies)
Discussion started by: iga3725
2 Replies

4. Shell Programming and Scripting

Find filenames with three digits and add zeros to make five digits

Hello all! I've looked all over the internet and this site and have come up a loss with an easy way to make a bash script to do what I want to do. I have a file with a naming convention as follows: 2012-01-18 string of words here 123.jpg 2012-01-18 string of words here 1234.jpg 2012-01-18... (2 Replies)
Discussion started by: Buzzman25
2 Replies

5. Shell Programming and Scripting

convert row to column with respect of first column.

Input file A.txt :- C2062 -117.6 -118.5 -117.5 C5145 0 0 0 C5696 0 0 0 Output file B.txt C2062 X -117.6 C2062 Y -118.5 C2062 Z -117.5... (4 Replies)
Discussion started by: asavaliya
4 Replies

6. Shell Programming and Scripting

Perl Script remove digits and convert

Hello Guy's Quick question which im sure many can answer in seconds. Basically I have a perl script which is running commands to an element and then taking some of the the output and printing it to the screen. One of the outputs is a variable Hex Number. What I would like to do is strip... (1 Reply)
Discussion started by: mutley2202
1 Replies

7. Shell Programming and Scripting

Convert Rows into Column

Hi Experts, I have a requirement to convert rows into columns. For e.g. Input File: Output File should be like Appreciate if you could suggest code snippet(may be awk) for above requirement... Thanks in Advance for your help... (3 Replies)
Discussion started by: sai_2507
3 Replies

8. Shell Programming and Scripting

Convert a column to a line

Hi, I need to convert my text file into a sort of matrix form. my input file has 5 columns. $2 and $4 will be ignored and omitted from output, while $3 need to be re-arranged horizontally on top:- Akd1 aa233 Akd1 545 524.2 jlk01 aa233 Akd1 90 447 mht5 ... (2 Replies)
Discussion started by: redse171
2 Replies

9. Programming

DB2 convert digits to binary format

Dear Team We use DB2 v10.5 and using DBArtisan tool Can someone please guide how to convert digits to binary numbers using db2 feature. Ex> for number 9 , binary should be 1001 ( 8+1) Any help appreciated. Thanks (2 Replies)
Discussion started by: Perlbaby
2 Replies

10. UNIX for Beginners Questions & Answers

sed / awk script to delete the two digits from first 3 digits

Hi All , I am having an input file as stated below 5728 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r03_q_reg_20_/Q 011 611 U_TOP_LOGIC/U_CM0P/core/u_cortexm0plus/u_top/u_sys/u_core/r04_q_reg_20_/Q 011 3486... (4 Replies)
Discussion started by: kshitij
4 Replies
PATGEN(1)						      General Commands Manual							 PATGEN(1)

NAME
patgen - generate patterns for TeX hyphenation SYNOPSIS
patgen dictionary_file pattern_file patout_file translate_file DESCRIPTION
This manual page is not meant to be exhaustive. See also the Info file or manual Web2C: A TeX implementation. The patgen program reads the dictionary_file containing a list of hyphenated words and the pattern_file containing previously-generated patterns (if any) for a particular language (not a complete TeX source file; see below), and produces the patout_file with (previously- plus newly-generated) hyphenation patterns for that language. The translate_file defines language specific values for the parameters left_hyphen_min and right_hyphen_min used by TeX's hyphenation algorithm and the external representation of the lower and upper case ver- sion(s) of all `letters' of that language. Further details of the pattern generation process such as hyphenation levels and pattern lengths are requested interactively from the user's terminal. Optionally patgen creates a new dictionary file pattmp.n showing the good and bad hyphens found by the generated patterns, where n is the highest hyphenation level. The patterns generated by patgen can be read by initex for use in hyphenating words. For a real-life example of patgen's output, see $TEXMFMAIN/tex/generic/hyphen/hyphen.tex, which contains the patterns TeX uses for English by default. At some sites, patterns for (many) other languages may be available, and the local tex programs may have them preloaded. All filenames must be complete; no adding of default extensions or path searching is done. FILE FORMATS
Letters When initex digests hyphenation patterns, TeX first expands macros and the result must entirely consist of digits (hyphenation levels), dots (`.', edge of a word), and letters. In pattern files for non-English languages letters are often represented by macros or other expandable constructs. For the purpose of patgen these are just character sequences, subject to the condition that no such sequence is a prefix of another one. Dictionary file A dictionary file contains a weighted list of hyphenated words, one word per line starting in column 1. A digit in column 1 indicates a global word weight (initially =1) applicable to all following words up to the next global word weight. A digit at some intercharacter position indicates a weight for that position only. The hyphens in a word are indicated by `-', `*', or `.' (or their replacements as defined in the translate file) for hyphens yet to be found, `good' hyphens (correctly found by the patterns), and `bad' hyphens (erroneously found by the patterns) respectively; when read- ing a dictionary file `*' is treated like `-' and `.' is ignored. Pattern file A pattern file contains only patterns in the format above, e.g., from a previous run of patgen. It may not contain any TeX comments or control sequences. For instance, this is not a valid pattern file: % this is a pattern file read by TeX. patterns{% ... } It can only contain the actual patterns, i.e., the `...'. Translate file A translate file starts with a line containing the values of left_hyphen_min in columns 1-2, right_hyphen_min in columns 3-4, and either a blank or the replacement for one of the "hyphen" characters `-', `*', and `.' in columns 5, 6, and 7. (Input lines are padded with blanks as for many TeX related programs.) Each following line defines one `letter': an arbitrary delimiter character in column 1, followed by one or more external representa- tions of that character (first the `lower' case one used for output), each one terminated by the delimiter and the whole sequence ter- minated by another delimiter. If the translate file is empty, the values left_hyphen_min=2, right_hyphen_min=3, and the 26 lower case letters a...z with their upper case representations A...Z are assumed. Terminal input After reading the translate_file and any previously-generated patterns from pattern_file, patgen requests input from the user's termi- nal. First the integer values of hyph_start and hyph_finish, the lowest and highest hyphenation level for which patterns are to be gener- ated. The value of hyph_start should be larger than any hyphenation level already present in pattern_file. Then, for each hyphenation level, the integer values of pat_start and pat_finish, the smallest and largest pattern length to be ana- lyzed, as well as good weight, bad weight, and threshold, the weights for good and bad hyphens and a weight threshold for useful pat- terns. Finally the decision (`y' or `Y' vs. anything else) whether or not to produce a hyphenated word list. FILES
$TEXMFMAIN/tex/generic/hyphen/hyphen.tex The original hyphenation patterns for English, by Donald Knuth and Frank Liang. $TEXMFMAIN/tex/generic/hyphen/ushyphmax.tex Maximal hyphenation patterns for English, extended by Gerard Kuiken. http://www.ctan.org/tex-archive/language/ Patterns and support for many other languages SEE ALSO
Frank Liang and Peter Breitenlohner, patgen.web. Frank Liang, Word hy-phen-a-tion by com-puter, STAN-CS-83-977, Stanford University Ph.D. thesis, 1983, http://tug.org/docs/liang. Donald E. Knuth, The TeXbook, Addison-Wesley, 1986, ISBN 0-201-13447-0, Appendix H. AUTHORS
Frank Liang wrote the first version of this program. Peter Breitenlohner made a substantial revision in 1991 for TeX 3. The first version was published as the appendix to the TeXware technical report. Howard Trickey originally ported it to Unix. Web2C 2012 7 April 2010 PATGEN(1)
All times are GMT -4. The time now is 11:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy