JCL SORT Decimal to Non decimal - mainframe

I want to convert a decimal value for e.g. 12.34 in input file to 1234 in output file. The field is defined as s9(11)v9(02) comp-3

Try this:
outrec fields=(1,13,pd,to=zd,length=25)

Related

I am trying to add multiple users from a CSV in Linux using CentOS [duplicate]

I have
while read $field1 $field2 $field3 $field4
do
$trimmed=$field2 | sed 's/ *$//g'
echo "$trimmed","$field3" >> new.csv
done < "$FEEDS"/"$DLFILE"
Now the problem is with read I can't make it split fields csv style, can I? See the input csv format below.
I need to get columns 3 and 4 out, stripping the padding from col 2, and I don't need the quotes.
Csv format with col numbers:
12 24(")25(,)26(")/27(Field2values) 42(")/43(,)/44(Field3 decimal values)
"Field1_constant_value","Field2values ",Field3,Field4
Field1 is constant and irrelevant. Data is quoted, goes from 2-23 inside the quotes.
Field2 fixed with from cols 27-41 inside quotes, with the data at the left and padded by spaces on the right.
Field3 is a decimal number with 1,2, or 3 digits before the decimal and 2 after, no padding. Starts at col 74.
Field4 is a date and I don't much care about it right now.
Yes, you can use read; all you've got to do is reset the environment variable IFS -- Internal Field Separator --, so that it won't split lines by its current value (default to whitespace), but by your own delimiter.
Considering an input file "a.csv", with the given contents:
1,2,3,4
2,3,4,5
6,3,2,1
You can do this:
IFS=','
while read f1 f2 f3 f4; do
echo "fields[$f1 $f2 $f3 $f4]"
done < a.csv
And the output is:
fields[1 2 3 4]
fields[2 3 4 5]
fields[6 3 2 1]
A couple of good starting points for you are here: http://backreference.org/2010/04/17/csv-parsing-with-awk/

calculate sum of a column excluding comma in between a number in bash scripting

This is the file(calculate.csv) which I have.
column1,column2,column3
10,'rohit', 123
20,'warner',-23
30,'anna',234
40,'shreya',19
50,'shravs',89
60,'vasu',12
100,'ajay',87
"1,000",'sumanth',-8
"2,000",'arjun',"1,228"
I need a command to calculate the sum of the column1
But it won't work for "1,000" and "2,000".
Is there any other way to ignore comma between quotes ""?
I need a sed command to ignore comma when it is in between "".
Ex:- "1,000",'sumanth' it should become 1000,'sumanth'.
The output should be 3310 for sum of column1.
The output should be 1761 for sum of column3.

Reading multiline standard input in J

Now I use this code to read data from standard input:
print =: 1!:2&2
read =: 1!:1[3
in =. (read-.LR)-.CR
But it returns just a sequence of numbers, e.g. input:
2
3
4
5
Output:
2345
Number of numbers is unknown, but each is in the separate line
When reading with (1!:1) you read a stream of characters. You have to manipulate the stream to get your desired input.
For example. If you want to enter a list of line separated integers, you would read the list, then split it by LF, remove LF and then convert to integer. You can achieve the first two steps using cut (;._2) and the conversion using do (".):
in =: ".;._2 (1!:1) 3
If you want to enter a list of space separated integers, you would just use do, the splitting would be implied by the spaces:
in =: ". LF -.~ (1!:1) 3
trailing LF (if present) has to be removed before applying ". because do can't convert special characters.

awk: format date string from YYYYMMDD to YYYY-MM-DD

I have a CSV file which I parse using awk because I don't need all columns.
The problem I have is that one column is a date but in the format YYYYMMDD but I need it in YYYY-MM-DD and I don't know how to achieve that.
I already tried with split($27, a) but it doesn't split it - so a[0] returns the whole string.
Use your awk output as input to date -d, e.g.
$ date -d 20140918 +'%Y-%m-%d'
2014-09-18
You could use substr:
printf "%s-%s-%s", substr($27,0,4), substr($27,5,2), substr($27,7,2)
Assuming that the 27th field was 20140318, this would produce 2014-03-18.

How to output octal values in ColdFusion

I have a series of octal values I'd like to output in their ASCII character equivalents. CHR does not seem to recognize an octal character when it sees it. Is there any straightforward way of doing this with ColdFusion?
Use InputBaseN to convert from Octal to Decimal, then you can use Chr to output the character.
For example:
Chr(InputBaseN( 101 , 8 )) => A
To go back the other way, you can reverse the process with Asc and FormatBaseN:
FormatBaseN( Asc('A') , 8 ) => 101

Resources