Excel: searching for a value within multiple arrays within cells - range

I'm trying to set up an error check between two systems and need to compare week numbers in different formats. One system produces week numbers in a text format e.g "8-15, 18, 31-32" and the other produces discrete values. How would I see whether a value e.g 16 fell within a multiple range like the one above?
It's part of a bigger issue where I'm checking a reference number, day, time and week number (e.g XXX111 Weds 9:00 9) in one system against the output of another system (e.g XXX111 Wed 9:00 7:11, 13, 16, 52-63 or XXX111 Thu 9:00 5, 6, 11-16). Despite lots of searching I've hit a wall with the bit above so any help would be greatly appreciated.
I'd rather not use VBA if possible. Thanks in advance for your wisdom.

Assumed:
7:11 should be 7-11
63 should be 53
A number not part of a range (eg 18) is not a problem
Ranges are in Text format
I hope the following helps or at least is ‘a step in the right direction’:
A Parse the components
Eg for 8-15, 18, 31-32, paste into a cell (say A1) and Data > Data Tools - Text to Columns > Delimited > Next > check Comma, Space and Treat consecutive delimiters as one > Next > Select Columns as required > select Text for each > Finish
May be easier to deal with a single column so select data, Copy > Select A2 > Paste Special > Transpose > OK and Delete contents of Row1.
B Add your search value (16) into B1
C Copy the formula below into B2 and copy down as required:
=AND(B$1>=VALUE(LEFT($A2,SEARCH("-",$A2)-1)),B$1<=VALUE(RIGHT($A2,LEN($A2)-SEARCH("-",$A2)))))
The result should be TRUE where the search value is within or on either bound of the discrete range:
The formula uses the hyphen to ‘recognise’ a discrete range. SEARCH looks for where it is positioned (because there could be one or two characters either side of it). LEFT and RIGHT are for the lower and upper bounds (in the case of RIGHT used in conjunction with LEN to address whether the upper bound is one or two characters). VALUE is required to convert the Text into something that can be equated to the search value. AND is for the process to consider both bounds in determining whether ‘in range’.
“I’d rather not use VBA if possible” – but might be advisable!
However, use of some fixed references ($) should make it a little easier than otherwise with standard formulae only because the given discrete ranges (which may be appended in ColumnA) can be queried for various search values by copying the formulae across to the right/down as required and entering (as Number format) further search values in Row1.

Related

Extracting data from old text file into usable format

I have some data in a text file in the following format:
1079,40,011,1,301 17,310 4,668 6,680 1,682 1,400 7,590 2,591 139,592 332,565 23,568 2,569 2,595 1,471 1,470 10,481 12,540 117,510 1,522 187,492 9,533 41,558 15,555 12,556 9,558 27,546 1,446 1,523 4000,534 2000,364 1,999/
1083,40,021,1,301 4,310 2,680 1,442 1,400 2,590 2,591 90,592 139,595 11,565 6,470 2,540 66,522 4,492 1,533 19,546 3,505 1,523 3000,534 500,999/
These examples represent what would be two rows in a spreadsheet. The first four values (in the first example, "1079,40,011,1") each go into their own column. The rest of the data are in a paired format, first listing a name of a column, designated by a number, then a space followed by the value that should appear in that column. So again, example: 301 17,310 4,668 6: in this row, column 301 has a value of 17, column 310 has value of 4, column 668 has value of 6, etc. Then 999/ indicates an end to that row.
Any suggestions on how I can transform this text file format into a usable spreadsheet would be greatly appreciated. There are thousands of "rows" and so can't just manually convert them and I don't possess the coding skills to execute such a transformation myself.
This is messy but since there is a pattern it should be doable. What software are you using?
My first idea would be to identify when the delimeter changes from comma to space. Is it based on a fixed width, like always after 14 characters? Or is it based on the delimiter, like it is always after the 4th comma?
Once you've done that, you could make two passes at the data. The first pass imports the first four values from the beginning of the line which are separated by comma. The second pass imports the remaining values which are separated by space.
If you include a row number when importing you can then use it to join first and second passes at importing.

JCL append date/time to a file?

How do I add the current date/time to a file in JCL?
For example, from the JCL:
//INPUT DD *
CGQ-TEST.ISQCQ.NET
ASCII
LOCSITE SBD=SYSP.FTP.RCAMSI
SENDSITE
PUT 'TJ.UTJ0IR86.BC814.HDR' BC814001.TMP
APPEND 'TJ.UTJ4IR86.BC(0)' BC814001.TMP
APPEND 'TJ.UTJ0IR86.BC814.TRL' BC814001.TMP
RENAME BC813001.TMP BC814001.TXT
CLOSE
QUIT
I need the file BC814001.TXT to actually be BC814001.20160930.110900.ent, where 20160930.110900 is current date and time (YYYYMMDD.HHMMSS format).
The best way to do this is to use the features of your job scheduling package (Control-M or one of its competitors). It's usually the most maintainable. Talk to your production control staff.
If for some reason that won't work for you, please see this answer.
The convention fd dataset level qualifiers limits you only to 8 characters per section (space between dots) and it should start with a character not a number.
Each name segment (qualifier) is 1 to 8 characters, the first of which must be alphabetic (A to Z) or national (# # $). The remaining seven characters are either alphabetic, numeric (0 - 9), national, a hyphen (-). Name segments are separated by a period (.).
For z/OS environments I would go with 'day of the year' for the actual date. For example in your case - BC814001.D2016274.T110900.ent.
To get the current date and time You can refer to the TSO DATE and TSO TIME via REXX and format them the way You like (examples here http://www.rexxla.org/rexxlang/mfc/datec.html) then pass them as a variable to your SYSIN statement.
Regards,
Jarek.

Ignore small difference between numbers in Beyond Compare

I have 2 files with some number values in it and I want to compare them using Beyond Compare. But if the difference between two numbers is small enough, I want Beyond Compare to ignore those differences.
For example, I have the file named file1.txt with the values:
value1: 10
value2: 8.2
value3: 5.7
and the second file named file2.txt with the values:
value1: 8
value2: 8.4
value3: 6.3
I want Beyond Compare to show me differences only where the difference between two numbers is greater than 0.5, in this case, on line 1 and line 3.
Can someone tell me how could I do that? I tried with regular expressions but I didn't succeed.
EDIT:
I tried the answer #Chris Kennedy told, and this is the outcome:
Beyond Compare's Text Compare doesn't support ignoring differences with a numeric tolerance. It can only ignore differences based on text matching using regular expressions or text delimiters.
Beyond Compare 3's Data Compare (Table Compare in BC4) does support numeric tolerances. Load files the Data Compare, then click on the Rules toolbar button (referee icon). Go to the Columns tab. Double click on a column to edit it. Uncheck "Use default". Set the Type dropdown to Numeric. Enter a numeric tolerance. Note that Numeric Tolerance isn't available if Key is checked in the column settings.

Raw Excel Data contains different Date formats

I have huge amounts of raw data that are separated by columns. All is well when i import these to Matlab except for the fact that I just saw that the excel files contains different formats for the dates.
One series (i.e 3 days, 1 row or each hour gets 3x24 rows) have its' dates in the format "mm/dd/yyyy" which neither excel or matlab recognizes as proper dates.
I've tried solving this problem in different ways. First i tried to just highlight the cells and use the function format cells, but this didn't work since excel doesn't see them as 'cells' but rather as 'text'.
Then i tried the Text to columns function which didn't work either (delimited or fixed width).
Im really stuck and would appreciate some help with this.
In Excel:
If cell A1 has a string like mm/dd/yyyy then try this:
=DATE(RIGHT(A1,4), LEFT(A1,2), MID(A1,4,2))
In Matlab:
=datenum(yourDateString, 'mm/dd/yyyy')
Select the desired range to fix and use this script:
Sub bulk_Date_fix()
on error resume next
Set d_ranged = Selection
For Each a In d_ranged
a.Value = Split(a.Value, "/")(0) & "/" & Split(a.Value, "/")(1) & "/" & Split(a.Value, "/")(2)
Next
on error goto 0
End Sub
How it works: The above script loops through all the cells in the selected area and splits out the various attributes of a date based on the "/" symbol.
I examined your file and you will need to go back to the source data to straighten this out. Instead of "opening" the file in Excel, you will need to IMPORT the file. When you do that, the text import wizard will open, and you can then designate the date column as being of the format DMY (or whatever format is being generated by the source).
The problem is that there is a mismatch between the format of the file, and your Windows Regional Short date format. If you look at Row 229, you will see that real dates are present, but out of sequence with the rest.
Excel parses dates being input according to the Windows Regional Short Date settings. If the date doesn't make sense, according to that parsing (e.g. month > 12) , Excel will interpret the date as a string; if the date does make sense, it will be interpreted as a date in accordance with that windows regional date component order, and this will be different from what is intended.
So the first few hundred dates are strings, but at line 229, the date, which is probably meant to be 12 OCT 2014, gets changed to 10 DEC 2014. This will happen in other areas where that value in the 2nd position is 12 or less.
EDIT: I am not certain of the variabilities inherent in using XL on the MAC. In the Windows version of XL, the "text import" feature is on the Data Ribbon / Get External Data Tab:
When you click on that and open a text file, you will see the Text Import Wizard, and when you get to Step 3, you will be able to specify the text format of the data to be imported:

How to fill a field with spaces until a length in Notepad++

I've prepared a macro in Notepad++ to transform a ldif file in a csv file with a few fields. Everything is OK but I have a final problem: I have to have 2 fields with a specific length and in this moment I cannot ensure that length because in the source file they are not coming so
For instance, I generate this line:
12345,namenamename,123456
And I have to ensure that the 2nd and 3rd fields have 30 (filling with spaces at right side) and 9 (filling with zeros at left) characters, so in this case I should generate:
12345,namenamename ,000123456
I haven't found how Notepad++ could match a pattern in order to add spaces/zeros, so I have though in to add 1 space/zero to the proper field and repeat this step so many times as needed to ensure the lengths (this is, 29 and 8, because they cannot come empty) and search with the length in the regex (for instance: \d{1,8} for the third field)
My question is: can I repeat only one step of the macro several times (and the rest of the macro only 1 repetition)?
I've read the wiki related to this point (http://sourceforge.net/apps/mediawiki/notepad-plus/index.php?title=Editing_Configuration_Files#.3CMacros.3E) and I don't found anything neither
If not possible, how could be a good solution? Create another 2 different macros and after execute the main one, execute this new 2 macros several times?
Thanks in advance!
A two pass solution with Notepad++ is possible. Find a pair of characters or two short sequence of characters that never occurs in your data file. I will use =#<= and =>#= here.
First pass, generate or convert the input text into the form 12345,=#<=namenamename______________________________,000000000123456=>#=. Ie add 30 spaces after the name and nine zeroes before the number (underscores used here just to make things clearer).
Second pass, do a regular expression search for =#<=(.{30})_*,0*(\d{9})=>#= and replace with \1,\2.
I have just suggested a similar solution in special timestamp format of csv