Create aligned columns
-
Hi all,
I would like to create columns out of the list of numbers I have.
The goal is to achieve the same column style of the first row of numbers (ROW8) that you can see in the picture (see link: http://imgur.com/a/afR3M ).
The following rows of numbers have the same length (same amount of digits as in ROW 8) but they have no spaces in between and I want them to get aligned.
Here there is a scheme of the [spaces] and the number of digits I would like to obtain.
[10] 10 [12] 8 [11] 9 [11] 9 [11] 9 [11] 9 [11] 9 [11] 9 [11] 9 [11] 9.Hopefully someone can help me with this!
Cheers,
Giuliana -
Hello, Giuliana,
Not very difficult with regular expressions !
From your picture, Giuliana, each line of your file ( 90 characters long ) must be separated, according to the template : “
10spaces - 10 digits - 12 spaces - 8 digits - ( 11 spaces 9 digits ) * 8”, to obtain a line of 200 characters longSo :
-
Open your file and move back to its very beginning, if necessary
-
Open the Replace dialog
-
Type, in the two *Find what: and Replace with: fields, the following regex expressions, WITHOUT the double quotes (
")
SEARCH "(?-s)^(.{10})(.{8})(.{9})(.{9})(.{9})(.{9})(.{9})(.{9})(.{9})(.{9})" REPLACE " $1 $2 $3 $4 $5 $6 $7 $8 $9 $10"-
Beware :
- There are
10space characters, between the"character and the back-reference$1 - There are
12space characters, between the the two back-references$1and$2 - Then, always
11space characters, between two back-references, till the end of the line
- There are
-
Check the Regular expression search mode ( IMPORTANT )
-
Finally, click on the Replace All button
So, starting, for instance, from the original line, below :
135012160427072098258328479258328482258328481258328480258328483258328486258328485258328484you’ll get the formatted text, below :
1350121604 27072098 258328479 258328482 258328481 258328480 258328483 258328486 258328485 258328484NOTES :
-
At beginning of the search regex, the syntax
(?-s)ensures you that the following dot characters refer to a single standard character, only -
The syntax
.{n}, wherenis a digit, represents n consecutive standard characters, from current caret position, -
As this syntax is enclosed within two round brackets, these
ncharacters are stored, successively, as group 1, 2, 3… -
And are re-written, in replacement, accordingly to the appropriate back-reference
$x, simply preceded by the correct amount of space characters
Cheers,
guy038
-
-
Thank you sooo much for your reply!!!
Very clear and exhaustive!Have a great weekend and thanks again :)
Cheers,
Giuliana
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login