How is the following text transposed into this hex output? - text

INPUT:
00:00:00:00 a
b
c
d
// NEWLINE separating each letter
OUTPUT:
Scenarist_SCC V1.0
00:00:00:00 9420 13d6 9723 6180 1376 9723 6280 94d6 9723 e380 9476 9723 6480 9420 942c 942f
00:00:01:00 942c
Here is some information about the format, but I'm struggling to understand how this text transformation is done.

What is it that you're using to convert the text to that string of Hex? Regardless, it would appear as though the Hex output is peppered with various CC commands. Just looking at the codes in the format document to which you linked I get the following:
Timecode 00:00:00:00: start pop-on caption (9420), move cursor to row 12, column 12 (13d6), move over three columns (9723), character "a" (6180), move cursor to row 13, column 12 (1376), move over three columns (9723), character "b" (6280), move cursor to row 14, column 12 (94d6), move over three columns (9723), character "c" (e380), move cursor to row 15, column 12 (9476), move over three columns (9723), character "d" (6480), start pop-on caption (9420), clear screen (942c), display caption (942f).
Timecode 00:00:01:00: clear screen (942c)
So whatever program you're using to produce the output is adding the CC formatting, positioning and other commands to the Hex stream.

Related

VIM : How to delete certain char range in every line

I'm trying to delete certain character range in each line of a file using VIM.
Sample file,
"2021-11-29T06:35:04.300-0500",01,342864
"2021-11-29T06:35:20.252-0500",54,332323
"2021-11-29T06:35:20.000-0500",63,513133
I want the result to be like this,
"2021-11-29T06:35:04",01,342864
"2021-11-29T06:35:20",54,332323
"2021-11-29T06:35:20",63,513133
I want to delete the characters after the seconds[.300-0500, .252-0500, .000-0500] in every line, throughout the file, i.e, char range 21-30.
How do I do this ?
I understand I can delete the char range from the start of the line or in the end of the line using below,
:%s/^.\{0,5\}//
:%s/.\{1}$//
You can use \%Xv to match (virtual) column X, so:
:%s/\%21v.*\%31v//
will delete characters between columns 21 and 30.
You could use:
:%s/\.\d\{3\}-\d\{4\}//
or
:%norm 20ld9l
That's move 20 columns to the left (from column 1, to column 21) and then delete from there until 21+9 = 30

Need excel formula to extract a single or double digit number preceding a character or symbol

Here's the case I have a column with a number of text strings. Each string contains either a single or double-digit number followed by either an "x" or the words " set" or " rounds." I'm trying to extract the numbers preceding the "x" or the words. Here's an example:
string
Desired Outcome
jump 3x10
3
push 10x3
10
pull 3 sets 10 times
3
pull 3 rounds 8 times
3
push 10 times 3 sets
3
I've tried FIND, SEARCH, {1,2,3,4, 5, 6,7, 8, 9} only to over-complicate this. There has to be a simple way to locate these combinations (##&"x", "## sets" or ""## rounds") and extract the related numbers.
Assume "String" data housed in Column A1:A6 with header.
In "Outcome" B2, formula copied down :
=LOOKUP(9^9,0+RIGHT(LEFT(A2,MIN(SEARCH({"x"," sets"," rounds"},A2&"x sets rounds"))-1),ROW(A$1:A$250)))

Automatic numbering in Excel with hierarchy

I would like to do an automatic summary numbering. The only thing we could do is to number the A's (the titles) but the subtitles should be numbered automatically. If the title = 1, subtitle 1.1, below 1.1.1 and so on.
Let's say the titles are A, B and C are subtibles.
The pattern should be like this
1.A
1.1 B
1.2 B
2.A
2.1 B
2.1.1 C
So I tried this : https://stackoverflow.com/a/32321112/7968011
What I get
What we want
What we want
If you have your Level Marker as "A" / "B" / "C" in Column A, and the heading in Column B, then you can use the following (convoluted) code:
=REPT(CHAR(9), CODE(A1)-65) & SUMPRODUCT(--(A:A="A")*--(ROW(A:A)<=ROW(A1))) & "." & IF(CODE(A1)>65,SUMPRODUCT(--(A:A="B")*--(ROW(A:A)<=ROW(A1))*--(ROW(A:A)>=MAX(--ROW(A:A)*--(A:A="A")*--(ROW(A:A)<=ROW(A1))))) & ".","") & IF(CODE(A1)>66,SUMPRODUCT(--(A:A="C")*--(ROW(A:A)<=ROW(A1))*--(ROW(A:A)>=MAX(--ROW(A:A)*--(A:A="B")*--(ROW(A:A)<=ROW(A1))))) & ".","") & CHAR(9) & B1
Let's break it down into steps:
Start with Tabs to indent the heading (0 for "A", 1 for "B", 2 for "C"): REPT(CHAR(9), CODE(A1)-65) where Char(9) is a Tab.
Next, we want to count how many "A"s have we had. We can use SUMPRODUCT to run this as an Array Formula, looking for cells where the value is "A" and the Row is <= current row: SUMPRODUCT(--(A:A="A")*--(ROW(A:A)<=ROW(A1))). Shove a dot after that, and you have your heading number.
Next, IF Column A is "B" or later in the alphabet (IF(CODE(A1)>65, since CODE("A")=65, CODE("B")=66, etc) then we want to count how many "B"s since the last "A". This is very similar to our last query, but we need a ROW(A:A)>=LAST_A. But, what is LAST_A? Well, we want the MAX Row where Column A = "A" and Row <= current row. So, MAX(--ROW(A:A)*--(A:A="A")*--(ROW(A:A)<=ROW(A1))).
This gives SUMPRODUCT(--(A:A="B")*--(ROW(A:A)<=ROW(A1))*--(ROW(A:A)>=MAX(--ROW(A:A)*--(A:A="A")*--(ROW(A:A)<=ROW(A1)))))
Now, we need to add the IF and the full-stop, to get
If(Code(A1)>65,SUMPRODUCT(--(A:A="B")*--(ROW(A:A)<=ROW(A1))*--(Row(A:A)>=MAX(--ROW(A:A)*--(A:A="A")*--(ROW(A:A)<=ROW(A1))))) & ".","")
Repeat the same for all "C"s since the last "B", and then finally add a Tab (CHAR(9)) and the value in Column B.
(If you want, for example, 4 spaces or 6 hyphens or 7 dots instead of Tabs at the start of the row or between the number and the tile, just replace the first or last CHAR(9))
{EDIT} Example:
Fast and dirty.
Just enter the first section manualy.
Then insert it below:
=IF(A3="down",B2&"1.",IF(A3="up",LEFT(B2,LEN(B2)-4)&MID(B2,LEN(B2)-3,1)+1&".",LEFT(B2,LEN(B2)-2)&MID(B2,LEN(B2)-1,1)+1&"."))
When you write "down" it will add "1." in the end of the string above.
When you write "up" it will remove the last 2 chars and add 1 to the last char of the string above.
if you dont write nothing it will add 1 to the last char.
bug: "up" will not work if section is > 9.

Aligning single and double digit number with space in csv

I have an excel-file that i need to save to a .csv or .txt to create a specific formatted file to a software I'm using. Two of the columns in the .csv or .txt contains data with single and double digit numbers. When saving excel-file to .csv or .txt these columns will be separated with the according separating value (semicolon, tab, aso.)
What I'm looking for is how to add a space in front of the single digit number so that it aligns to the right properly with the double digit number. I have tried to figure this out in the custom number formatting but I always end up with spaces both in front of the double digit and single digit.
To try and illustrate (left side is standard csv, right side is what I'm looking for):
;14;3; --> ;14; 3;
;12;22; --> ;12;22;
;13;5; --> ;13; 5;
The displayed format (cell number formatting) is exported as the CSV element value. Use a number format of [>9]0;_(0 to add a prefacing space to single digit values.
col1,col2,col3
AA, 2,2.00
BB, 3,3.00
CC, 4,4.00
DD, 5,5.00
EE, 6,6.00
FF, 7,7.00
GG, 8,8.00
HH, 9,9.00
II,10,10.00
JJ,11,11.00
KK,12,12.00
LL,13,13.00
MM,14,14.00
The middle field receive the custom number format.

How to duplicate the lines and replace multiple string in ONE Tab Separated File

I have a incoming file like (in.txt) which is a Tab Separated File and NO Header line in it.
I want to duplicated each row TWO times and do the replacement (base on the rules).
I am new in *nux, i am totally no idea what tools can help me to do this.
The Incoming file (in.txt. Separated by Tab(\t))
A B C D E F G H
1 855211046 2/3/2015 $170.00 4154245328852953 328573 1809 CC786875287728777
2 855211046 3/3/2015 $100.10 5524415875875844 822409 1809 CC150330106885244
3 855211046 30/3/2015 $105.00 4875875852875211 445092 1809 CC456387885245062
etc.
The Expected Outcome (Outcome.txt)
^2.{32}(855211046000).{8}(150302)
^5(855211046000).{7}(4154245328852953 ).{60}(150302)(328573).{10}\s{1}(000000017000)
^5(855211046000).{7}(4154245328852953 ).{60}(150302)(328573).{122}(000000017000)
^2.{32}(855211046000).{8}(150303)
^5(855211046000).{7}(5524415875875844 ).{60}(150303)(822409).{10}\s{1}(000000010010)
^5(855211046000).{7}(5524415875875844 ).{60}(150303)(822409).{122}(000000010010)
^2.{32}(855211046000).{8}(150330)
^5(855211046000).{7}(4875875852875211 ).{60}(150330)(445092).{10}\s{1}(000000010500)
^5(855211046000).{7}(4875875852875211 ).{60}(150330)(445092).{122}(000000010500)
Rules
*1st record*
^2.{9}.{7}.{16}([Column B's data, 0 fill right till the position 12]).{8}([Column C's data but reformat to YYMMDD format])
^5([Column B's data, 0 fill right till the position 18]).{7}([Column E's data, SPACE fill right till the position 19]).{60}([Column C's data but reformat to YYMMDD format])([Column F's data]).{10}\s{1}([Column D's data but remove $ sign and then multiplied by 100])
^5([Column B's data, 0 fill right till the position 18]).{7}([Column E's data, SPACE fill right till the position 19]).{60}([Column C's data but reformat to YYMMDD format])([Column F's data]).{122}([Column D's data but remove $ sign and then multiplied by 100])
*2nd record*
same as 1st
*3rd record*
same as 1st
Thanks a lot.
It is not difficult but require attention and some typewriting:
awk '
/./{
split($3,T,"/")
$3=sprintf("%d%02d%02d",T[3]-2000,T[2],T[1])
sub("\\$","",$4);$4*=100
printf "^2.{9}.{7}.{16}(%d%0."12-length($2)"d).{8}(%d)\n",$2,0,$3
printf "^5(%d%0."18-length($2)"d).{7}(%-19d).{60}(%d)(%d).{10}\\s{1}(%012d)\n",$2,0,$5,$3,$6,$4
...
}' in.txt >Outcome.txt
I am sure that you easyly add printf for 3rd line output according to above example.

Resources