Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Converting a text file with irregular spacing into a space delimited text file? Post 302552130 by evelibertine on Thursday 1st of September 2011 04:37:19 PM
Old 09-01-2011
Converting a text file with irregular spacing into a space delimited text file?

I have a text file with irregular spacing between values which makes it really difficult to manipulate. Is there an easy way to convert it into a space delimited text file so that all the spaces, double spaces, triple spaces, tabs between numbers are converted into spaces. The file looks like this:

Code:
1331  1 12 13 1  93.620   0.960  -0.420  57.410   1/  2   1/  1   1/  1   1/  2   
 1331  2 14 15 2  91.230   0.670 -99.999  49.980   0/  0   1/  2   1/  1   1/  2   
 1331  3  1  2 2  87.490   0.620 -99.999  47.890   1/  2   1/  2   1/  1   1/  2   
 1331  4  1  2 1  90.260   1.070 -99.999  63.810   0/  0   1/  1   1/  1   2/  2   
 1331  5  1  2 2  93.900   0.450 -99.999  57.440   1/  2   1/  1   1/  1   0/  0   
 1331  6  1  2 2  91.280   0.270 -99.999  59.970   1/  2   1/  1   1/  1   1/  2   
 1331  7  1  2 2  90.450   0.780  -0.090  51.850   1/  1   1/  2   1/  1   1/  1   
 1331  8  1  2 2  92.050   0.570   0.920  54.130   0/  0   1/  1   1/  1   0/  0

Thanks a lot!

Last edited by radoulov; 09-01-2011 at 06:01 PM.. Reason: Code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Searching for text in a Space delimited File

Hi I am trying to search a firewall syslog space delimeted file for all of the different tcp and udp destination ports. I know that grep will find lines that contain specific text. And I have tried using the the the cut command to cut out of the file certain colums. However the test I am... (6 Replies)
Discussion started by: andyblaylock
6 Replies

2. UNIX for Dummies Questions & Answers

Converting Space delimited file to Tab delimited file

Hi all, I have a file with single white space delimited values, I want to convert them to a tab delimited file. I tried sed, tr ... but nothing is working. Thanks, Rajeevan D (16 Replies)
Discussion started by: jeevs81
16 Replies

3. Shell Programming and Scripting

replace 3rd field of space delimited text file

how to replace the 3rd colum? Each line begins similarly, but they all ends variously. XX YY 03 variable text here XX YY 03 more variable text here XX YY 03 even more variable text here really long setence XX YY 03 variable numbers also appear 03 11. 123 456 XX YY 03 the occasional comma,... (4 Replies)
Discussion started by: ajp7701
4 Replies

4. UNIX for Dummies Questions & Answers

Deleting columns from a space delimited text file

I have a space delimited text file with 1,000,000+ columns and 100 rows. I want to delete columns 2 through 5 (2 and 5) included from the text file. How do I do that? Thanks. (3 Replies)
Discussion started by: evelibertine
3 Replies

5. UNIX for Dummies Questions & Answers

Deleting cells that contain a specific number only from a space delimited text file

I have this space delimited large text file with more than 1,000,000+ columns and about 100 rows. I want to delete all the cells that consist of just 2 (leave 2's that are not by themselves intact): File before modification aa bb cc 2 NA100 dd aa b1 c2 2 NA102 de File after modification... (1 Reply)
Discussion started by: evelibertine
1 Replies

6. UNIX for Dummies Questions & Answers

How do you view specific columns from a space delimited text file?

I have a space delimited text file with 1,000,000+ columns? I would only like to view specific ones (let's say through 1:10), how can I do that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

7. UNIX for Dummies Questions & Answers

Deleting lines that contain a specific string from a space delimited text file?

Hi, I have a space delimited text file that looks like the following: 250 rs10000056 0.04 0.0888 4 189321617 250 rs10000062 0.05 0.0435 4 5254744 250 rs10000064 0.02 0.2403 4 127809621 250 rs10000068 0.01 NA 250 rs1000007 0.00 0.9531 2 237752054 250 rs10000081 0.03 0.1400 4 17348363... (5 Replies)
Discussion started by: evelibertine
5 Replies

8. UNIX for Dummies Questions & Answers

Adding tags to a specific column of a space delimited text file

I have a space delimited text file with two columns. I would like to add NA to the first column of the text file. Input: 19625 10.4791768259 19700 10.8146489183 19701 10.9084026759 19702 10.9861346978 19703 10.9304364984 Output: NA19625 10.4791768259 NA19700 10.8146489183... (1 Reply)
Discussion started by: evelibertine
1 Replies

9. UNIX for Dummies Questions & Answers

Swap two rows in a space delimited text file?

Hi, How do you swap two rows in a space delimited text file? Thanks! (4 Replies)
Discussion started by: evelibertine
4 Replies

10. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies
Version::Next(3pm)					User Contributed Perl Documentation					Version::Next(3pm)

NAME
Version::Next - increment module version numbers simply and correctly VERSION
version 0.002 SYNOPSIS
use Version::Next; my $new_version = next_version( $old_version ); DESCRIPTION
This module provides a simple, correct way to increment a Perl module version number. It does not attempt to guess what the original version number author intended, it simply increments in the smallest possible fashion. Decimals are incremented like an odometer. Dotted decimals are incremented piecewise and presented in a standardized way. If more complex version manipulation is necessary, you may wish to consider Perl::Version. USAGE
This module uses Sub::Exporter for optional exporting. Nothing is exported by default. "next_version" my $new_version = next_version( $old_version ); Given a string, this function make the smallest logical increment and returns it. The input string is very minimally checked that it resembles a version number. Given "undef", the function returns 0. Decimal versions are incremented like an odometer, preserving the original number of decimal places. If an underscore is present (indicating an "alpha" version), its relative position is preserved. Examples: 0.001 -> 0.002 0.999 -> 1.000 0.1229 -> 0.1230 0.12_34 -> 0.12_35 0.12_99 -> 0.13_00 Dotted-decimal versions have the least significant element incremented by one. If the result exceeds 999, the element resets to 0 and the next most significant element is incremented, and so on. Any leading zero padding is removed. Examples: v1.2.3 -> v1.2.4 v1.2.999 -> v1.3.0 v1.999.999 -> v2.0.0 v1.2.3_4 -> v1.2.3_5 v1.2.3_999 -> v1.2.4_0 SEE ALSO
o Perl::Version AUTHOR
David Golden <dagolden@cpan.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2010 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004 perl v5.10.1 2010-10-01 Version::Next(3pm)
All times are GMT -4. The time now is 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy