02-22-2010
script to sort a string of numerical data in set fields
So, I will be working with someone and basically we are trying to build a form that is submitted most likely via the web and the data is just a string of numbers.
like:
19383882872201110929282821818182827349190102837364718191001932873711
Now, each number is part of a numerical value of some data they want. It will always be sent like this in plain text but there is a pattern to it. Like the first 5 digits are data entry A, the next 8 digits are data entry B, the next 3 digits are for C and so forth.
Then I need to output it so it is like this
A = 19383
B = 88287220
C = 111
I don't know all the details but these numbers plug into some system for data analysis and I just need to be able to organize the data for whomever is going to input it. I have no clue if this will be done email or web form. I told them to just send me a plain text file to begin with. I will have to split up each huge string of numbers and assign them to the proper value. I also do not know the patterns yet, but every giant string of numbers will contain the same amount of digits and be in the same pattern.
Now, lets say it is over web, I could have php invoke the shell or run a shell script correct?
Thanks in advance for any insight
-tl
9 More Discussions You Might Find Interesting
1. Programming
Hi I was hoping that maybe someone could help me with a small piece of C code. I have a number of files, which are all of similar layout ie. three lines of text and 5-6 columns of numerical data. I need to add each of the elements of the second column in one file to their counterparts in the second... (17 Replies)
Discussion started by: Boucho
17 Replies
2. Shell Programming and Scripting
Hi,
How can I remove all non numerical data from line, so I don't want to delete the line but to have only the numbers.
e.g.:
#########
123
aaa124
125bbb
126
127
#########
So I want all the leading and trailing non numerical stuff(letters/white space/tabs anything else except... (10 Replies)
Discussion started by: Juha
10 Replies
3. Shell Programming and Scripting
Hi All,
I have a .csv file with 3 columns called nLats, nLongs, and fRes. in following format :
"nLats","nLongs","fRes"
0,0,-1
0,1,-1
0,2,-1
0,3,-1
0,4,-1
.........
.........
0,143,-1 nLats increments at nLongs=143
1,0, -1
1,1, -1
..........
..........
1,143,-1... (1 Reply)
Discussion started by: wizardy_maximus
1 Replies
4. Shell Programming and Scripting
Hi,
I've searched and couldn't find anyone else with this problem. Is there anyway (preferably using ksh - but other script languages would do) that I can read in binary float data into a text file. The data (arrays from various stages of radar processing) comes in various formats, but mainly... (3 Replies)
Discussion started by: Jonny2Vests
3 Replies
5. Shell Programming and Scripting
Hello,
I have this sample data:
01 * * * *
01 * * * *
01 * * * *
01 * * * *
01 0 * * *
01 0 * * *
01 0 * * *
01 0 * * *
02 * * * 0
02 * * * 0
02 * * * 6
02 * * * 6
02 0 * * 1
02 0 * * 1
02 0 * * 2
02 0 * * 2
02 0 * * 3 (3 Replies)
Discussion started by: gio001
3 Replies
6. UNIX for Dummies Questions & Answers
I have a column of numbers in the following format:
1.722e-05
2.018e-05
2.548e-05
2.747e-05
7.897e-05
4.016e-05
4.613e-05
4.613e-05
5.151e-05
5.151e-05
5.151e-05
6.1e-05
6.254e-05
7.04e-05
7.12e-05
7.12e-05 (6 Replies)
Discussion started by: evelibertine
6 Replies
7. Shell Programming and Scripting
Hi
I have a file as below
<field1> <field2> <field3> ... <field_num1> <field_num2>
Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields.
I tried this and it doesn't sort on the difference field .. Appreciate your help.
cat... (9 Replies)
Discussion started by: newstart
9 Replies
8. Shell Programming and Scripting
How to sort the following output based on lowest to highest BE?
The following sort does not work.
$ sort -t. -k1,1n -k2,2n bfd.txt
BE31.116 0s 0s DOWN DAMP
BE31.116 0s 0s DOWN DAMP
BE31.117 0s 0s ... (7 Replies)
Discussion started by: sand1234
7 Replies
9. Shell Programming and Scripting
I have a string of pre defined ip address list which will always remain constant their order will never change like in below sample:
iplist=8.8.5.19,9.7.5.14,12.9.9.23,8.8.8.14,144.1.113
In the above example i m considering only 5 ips but there could be many more.
Now i have a file which... (15 Replies)
Discussion started by: mohtashims
15 Replies
LEARN ABOUT DEBIAN
algorithm::checkdigits::mbase_003
CheckDigits::MBase_003(3pm) User Contributed Perl Documentation CheckDigits::MBase_003(3pm)
NAME
CheckDigits::MBase_003 - compute check digits for SICI (Serial Item and Contribution Identifier)
SYNOPSIS
use Algorithm::CheckDigits;
$sici = CheckDigits('sici');
if ($sici->is_valid('0784-8679(20040308)6:<138>2.0.TX;2-H')) {
# do something
}
$cn = $sici->complete('0784-8679(20040308)6:<138>2.0.TX;2-');
# $cn = '0784-8679(20040308)6:<138>2.0.TX;2-H'
$cd = $sici->checkdigit('0784-8679(20040308)6:<138>2.0.TX;2-H');
# $cd = 'H'
$bn = $sici->basenumber('0784-8679(20040308)6:<138>2.0.TX;2-H');
# $bn = '0784-8679(20040308)6:<138>2.0.TX;2-';
DESCRIPTION
ALGORITHM
0 In the string describing the number all letters (A-Z) are replaced with numbers 10-35 accordingly. All other non-numbers are replaced
by 36.
1 Beginning right the numbers at all odd positions are added.
2 The sum from step 1 is multiplied by 3.
3 Beginning right the numbers at all even positions are added.
4 The sums from step 2 and 3 are added.
5 The sum from step 4 is taken modulo 37.
6 The checksum is 37 minus the sum from step 5 where numbers from 10 to 35 are represented by 'A' to 'Z' accordingly and 36 is
represented by '#'.
METHODS
is_valid($number)
Returns true only if $number consists solely of numbers and hyphens and the two digits in the middle are valid check digits according
to the algorithm given above.
Returns false otherwise,
complete($number)
The check digit for $number is computed and inserted into the middle of $number.
Returns the complete number with check digit or '' if $number does not consist solely of digits, hyphens and spaces.
basenumber($number)
Returns the basenumber of $number if $number has a valid check digit.
Return '' otherwise.
checkdigit($number)
Returns the check digits of $number if $number has valid check digits.
Return '' otherwise.
EXPORT
None by default.
AUTHOR
Mathias Weidner, <mathias@weidner.in-bad-schmiedeberg.de>
SEE ALSO
perl, CheckDigits, www.pruefziffernberechnung.de, http://sunsite.berkeley.edu/SICI/sici.pdf
perl v5.10.0 2008-05-17 CheckDigits::MBase_003(3pm)